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

Badly formed locations for Pexp_fun after 5.2 leads to Merlin confusion #503

Closed
jchavarri opened this issue Jun 30, 2024 · 0 comments · Fixed by #504
Closed

Badly formed locations for Pexp_fun after 5.2 leads to Merlin confusion #503

jchavarri opened this issue Jun 30, 2024 · 0 comments · Fixed by #504

Comments

@jchavarri
Copy link
Contributor

jchavarri commented Jun 30, 2024

Hi! Thanks for your work on ppxlib ❤️

We have stumbled upon this problem. Consider this file input.ml:

let make ~foo ~bar = foo ^ bar

Before 5.2, the locations for this file were the following (I cleaned up the ocaml.ppx.context part as it's not relevant for the issue and formatted them):

locations_5_1.txt

In 5.2, the locations are as follow:

locations_5_2.txt

Here's the diff between both files for clarity:

174,175c174,175
<               ((pos_fname input.ml) (pos_lnum 1) (pos_bol 0) (pos_cnum 30)))
<              (loc_ghost true)))
---
>               ((pos_fname input.ml) (pos_lnum 1) (pos_bol 0) (pos_cnum 18)))
>              (loc_ghost false)))

This location corresponds to the Pexp_fun ast node that corresponds to the ~bar argument. The change of location is problematic, because this AST node locations ends up being 14-18, while it has children that exceed that range, like a Pexp_apply which is immediate child with locations 21-30. Badly formed locations like this leads to issues with Merlin, in our experience.

Is this something possible due to the 5.1 -> 5.2 migration? is there anything we could do on our side to work around this problem? See related issue: reasonml/reason-react#840

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 a pull request may close this issue.

1 participant