Skip to content

Fix CoreFn FromJSON version parsing and add test#3877

Merged
hdgarrood merged 2 commits intopurescript:masterfrom
paulyoung:paulyoung/fix-corefn-version-parsing
May 18, 2020
Merged

Fix CoreFn FromJSON version parsing and add test#3877
hdgarrood merged 2 commits intopurescript:masterfrom
paulyoung:paulyoung/fix-corefn-version-parsing

Conversation

@paulyoung
Copy link
Copy Markdown
Contributor

I noticed that a value of 0.13.6 in corefn.json was being parsed as 0. This fixes that, and adds a test.

This bug appears to have been around since #3049, so about 3 years 😎

ann = ssAnn ss

specify "should parse version" $ do
let v = Version [0, 13, 6] []
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the old implementation, using let v = Version [0] [] here still allowed this test to pass.

@paulyoung paulyoung changed the title Fix CoreFn version parsing and add test Fix CoreFn FromJSON version parsing and add test May 16, 2020
Copy link
Copy Markdown
Member

@kritzcreek kritzcreek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just one nit about dependency order

import Language.PureScript.AST.Literals
import Language.PureScript.CoreFn.Ann
import Language.PureScript.CoreFn
import Language.PureScript.Docs.Types (parseVersion')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That dependency seems the wrong way around. Could we move that parseVersion' somewhere both the Docs and CoreFn can import from?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. Do you have any suggestions on where to put it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked around a bit and I can't come up with anything better than just putting it into CoreFn.FromJSON. @hdgarrood any preferences?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we should just dump this sort of stuff - stuff we kind of wished was provided by upstream libraries - into a Language.PureScript.Utils module. There are some modules in the compiler already for this sort of stuff which don’t use the Language.PureScript namespace but they really ought to, imo. But that’s probably separate... for now I don’t mind having one of these import the other. I don’t have a preference for which way around they are.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allright, in that case I'd prefer the function lived here. I see ide/docs/publish as downstream from the compilers PoV.

@hdgarrood hdgarrood merged commit 1b91bda into purescript:master May 18, 2020
@hdgarrood
Copy link
Copy Markdown
Contributor

Thanks!

@paulyoung paulyoung deleted the paulyoung/fix-corefn-version-parsing branch May 18, 2020 15:03
@hdgarrood hdgarrood mentioned this pull request May 23, 2020
hdgarrood pushed a commit that referenced this pull request May 23, 2020
* Fix CoreFn version parsing and add test

* Move parseVersion' to CoreFn.FromJSON module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants