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 numeric parsing for GHCJS #1681

Merged
merged 3 commits into from
Feb 22, 2020
Merged

Fix numeric parsing for GHCJS #1681

merged 3 commits into from
Feb 22, 2020

Conversation

Gabriella439
Copy link
Collaborator

The fix from #1647 broke GHCJS support for Dhall. Specifically, any Dhall
code containing numeric literals would fail to parse when using GHCJS.

The consequence of this is that the final example from the online demo
currently does not work because it uses at least one number.

The root cause was this issue:

ghcjs/ghcjs-base#62

The change to use Text.Megaparsec.Char.Lexer.float triggered the above
problem, because float depended transitively on Data.Char.toTitle which
was not working for the version of GHCJS that we currently build against.

The fix is to reimplement the logic for parsing double literals by
following the standard grammar instead of reusing an existing utility.
However, I cribbed quite a bit from the existing logic for
Text.Parser.Char.double along the way.

The fix from #1647 broke GHCJS support for Dhall.  Specifically, any Dhall
code containing numeric literals would fail to parse when using GHCJS.

The consequence of this is that the final example from the online demo
currently does not work because it uses at least one number.

The root cause was this issue:

ghcjs/ghcjs-base#62

The change to use `Text.Megaparsec.Char.Lexer.float` triggered the above
problem, because `float` depended transitively on `Data.Char.toTitle` which
was not working for the version of GHCJS that we currently build against.

The fix is to reimplement the logic for parsing double literals by
following the standard grammar instead of reusing an existing utility.
However, I cribbed quite a bit from the existing logic for
`Text.Parser.Char.double` along the way.
Copy link
Collaborator

@sjakobi sjakobi left a comment

Choose a reason for hiding this comment

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

Nice catch!

Maybe a comment referencing the GHCJS bug might be useful for a future reader who wonders why we don't use a standard float parser?!

Also: Should we try to run the testsuite with GHCJS in CI (and thereby catch such bugs earlier)? Not sure how tricky that would be though…

@Gabriella439
Copy link
Collaborator Author

@sjakobi: I can add a comment, but don't think we can enable the tests. I left a comment at one point saying that the test suite doesn't work on GHCJS:

# Test suite doesn't work on GHCJS

... although I don't remember the exact reason why

For some reason `-- * ${URL}` is not allowed in a comment?
@mergify mergify bot merged commit 5b29700 into master Feb 22, 2020
@mergify mergify bot deleted the gabriel/fix_ghcjs_2 branch February 22, 2020 00:14
Gabriella439 added a commit to dhall-lang/dhall-lang that referenced this pull request Feb 22, 2020
This fixes a GHCJS bug that causes code with numbers to fail to parse

See: dhall-lang/dhall-haskell#1681
Gabriella439 added a commit to dhall-lang/dhall-lang that referenced this pull request Feb 23, 2020
This fixes a GHCJS bug that causes code with numbers to fail to parse

See: dhall-lang/dhall-haskell#1681
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants