-
Notifications
You must be signed in to change notification settings - Fork 177
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 locations in generated lwt ppx #470
Conversation
…e whole expression Previously the location was only set to the location of the binding ("pat = expr") part. However, since it spans both the pattern and the body, it needs to be given a location that contains both. Fixes ocsigen#337.
I found the same fixes independently (but @copy was faster :-)), so I believe this PR is correct. |
Thanks. I will try to check it on my code this weekend. Does it affect only let or match, try and finally too? Is there a way to add tests for this BTW? |
Tests are interesting. Would we maybe run a merlin query on every character of the file, and expect some result of correct locations from it? Of course, I think such a setup shouldn't be part of this PR or the issue it closes. |
It looks good from what I checked. I'm just waiting for a last confirmation from @Engil |
Thanks to all involved! @Khady No worries, we're all busy :) @copy I believe you need to claim the bounty on Bountysource, I guess the proper link for that is here: https://www.bountysource.com/issues/43966981-lwt-ppx-reports-incorrect-locations And here is some background info linked by @Khady: http://blog.bountysource.com/post/59038181176/weve-improved-how-bounties-are-awarded |
Well, there are two things to test for locations in pxxs: merlin is one, but another one is to look at the locations of type error messages returned by the compiler, which is fairly easy to automate using the toplevel (didn't we had that in lwt at some point? At least we do in jsoo and tyxml). @copy Did you tested that? In particular, I'm not convinced by the 3rd commit. |
I tested the changes manually using @Drup What are your doubts about the third commit? It does use ghost locations, however only for the catch-all pattern |
I wrote some expect tests using the toplevel as @Drup suggested. I wasn't sure how to integrate them into lwt's build system, so the tests are in a separate repository for now: https://github.com/copy/lwt-ppx-expect-tests. The results look good (in my view), but I also lacked creativity to create type errors (usually I fix them ;-)), so a review would be welcome. cc @aantron |
@copy you can see Bisect_ppx as a reference. Its entire test suite is basically expect tests fit into the OUnit model, though it's much more elaborate that what's necessary for Lwt (due to the number and diversity of tests, and some other factors). It's all centered on calling |
This fixes two problems in the generation of
let%lwt
expressions:Lwt.bind t (fun v -> body)
) didn't contain the actual body (first commit)For reference, the diff between the broken parse tree and the fixed one: https://gist.github.com/copy/97aafc69a2467fa390e3f02f5aa97f09 By manual inspection, the locations look correct now.
This fixes #337.