Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CoreFn FromJSON version parsing and add test #3877

Merged

Conversation

paulyoung
Copy link
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 😎

@@ -47,6 +47,15 @@ spec = context "CoreFnFromJsonTest" $ do
ss = SourceSpan mp (SourcePos 0 0) (SourcePos 0 0)
ann = ssAnn ss

specify "should parse version" $ do
let v = Version [0, 13, 6] []
Copy link
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
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.SourcePos (SourceSpan(SourceSpan))
import Language.PureScript.AST.Literals
import Language.PureScript.CoreFn.Ann
import Language.PureScript.CoreFn
import Language.PureScript.Docs.Types (parseVersion')
Copy link
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
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
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
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
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
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