-
Notifications
You must be signed in to change notification settings - Fork 212
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 parser swallowing whitespace in Src annotations #1563
Conversation
The parser annotated application expressions incorrectly: whitespace between function and argument was swallowed when constructing the Src annotation. This bug resulted in strange behaviour in the hovering functionality in dhall-lsp-server. As an example, previously the Dhall expression `0 0` would be parsed as ``` Note (Src {..., srcText = "00"}) (App (Note (Src {..., srcText = "0"}) (NaturalLit 0)) (Note (Src {..., srcText = "0"}) (NaturalLit 0))) ``` while we now get ``` Note (Src {..., srcText = "0 0"}) (App (Note (Src {..., srcText = "0"}) (NaturalLit 0)) (Note (Src {..., srcText = "0"}) (NaturalLit 0))) ``` as expected.
As suggested by @sjakobi. Note that there are quite a few more occurences of foldl where we don't actually need laziness, but I leave that for someone else to fix :)
Can you make an issue so we don't forget about it? |
Good point ;) |
This reverts commit 1bd9a54.
I made a separate pull request for using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should come up with a way to test the Note
s that we parse directly: Find out what properties dhall-lsp-server
relies on and try to put them into property tests…
| Note (Src left _ bytesL) _ <- a | ||
, Note (Src _ right bytesR) _ <- b | ||
= Note (Src left right (bytesL <> sep <> bytesR)) (App a b) | ||
app a (_, b) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| otherwise
would work too, but it doesn't matter a lot.
Feel free! I don't think this is as trivial as one would hope, since we really want to test all The only way I see to go about this is to construct a 'concatenative' pretty-printer and to compare the |
The parser annotated application expressions incorrectly: whitespace
between function and argument was swallowed when constructing the Src
annotation. This bug resulted in strange behaviour in the hovering
functionality in dhall-lsp-server.
As an example, previously the Dhall expression
0 0
would be parsed aswhile we now get
as expected.