Closed jchavarri closed 2 weeks ago
I didn't think about it when reviewing #504 but we indeed have something like this in the codebase already, see location_check.mli
.
It's disabled by default but you can enable it by passing -location-check
to the driver invocation in which case it will perform the check on the fully transformed AST.
Let me know if that fits your needs!
I'll refactor the tests for your migration fix to use this instead!
😮 wow, TIL. Thanks!
For reference, to get this to work you need to pass both -check
and -locations-check
to the driver, passing simply the latter won't work. I'll look into fixing this!
I opened a PR with a fix: #506
I'll include this in the next release!
Merlin expects locations to be well-formed. The only reference to what "well-formed" means that I could find is here: https://github.com/ocaml/ocaml/pull/8987. Copying for posterity:
I wonder if ppxlib could include a
check_locations_integrity
tool to check the locations of a given AST to make sure they comply with these rules. This tool would be useful for both ppxlib maintainers and the larger ecosystem of ppx authors alike.As an example, right now in reason-react we have to analyze full trees of AST nodes doing this work manually, which is very time consuming.
See related: #503 and its fix #504 where a small subset of what this tool could look like is implemented.