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

Add locations-check test #844

Merged
merged 2 commits into from
Aug 15, 2024
Merged

Add locations-check test #844

merged 2 commits into from
Aug 15, 2024

Conversation

jchavarri
Copy link
Collaborator

@jchavarri jchavarri commented Jul 1, 2024

I found out today that ppxlib has some -check -locations-check flag that one can use to make sure a ppx generates an AST with valid locations ("valid" in the sense of following the Merlin rules).

I thought this could serve as an alternative to tests like the one @anmonteiro adds in #842 and the many other merlin-based tests that we have.

Rather than building the test based on what merlin returns, we can just make sure the tree is well formed. But it turns out the check doesn't successfully pass (even in 5.1), because there are too many overlaps.

Maybe we can keep the test as is for now and over time solve all issues until we make sure it passed this check. @davesnx @anmonteiro wdyt?

File "input.ml", line 1, characters 33-36:
1 | let[@react.component] make ~foo ~bar =
^^^
Error: invalid output from ppx, core type overlaps with core type at location:
Copy link
Member

Choose a reason for hiding this comment

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

Woa

Copy link
Member

@anmonteiro anmonteiro left a comment

Choose a reason for hiding this comment

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

pretty nice.

I wonder if the failing tests will now pass after the ppxlib 0.33 release

@jchavarri
Copy link
Collaborator Author

I wonder if the failing tests will now pass after the ppxlib 0.33 release

They do. I just had to modify one location in the ppx tests (seems not harmful).

@jchavarri jchavarri merged commit a9f8c77 into main Aug 15, 2024
3 checks passed
@jchavarri jchavarri deleted the jchavarri/locations-check branch August 15, 2024 10:47
@jchavarri
Copy link
Collaborator Author

They do. I just had to modify one location in the ppx tests (seems not harmful).

Hm just realized this change was already in #850. I forgot to merge main into this branch 🤦


$ reason-react-ppx -check -locations-check input.ml
File "input.ml", line 2, characters 3-6:
2 | (div
Copy link
Member

Choose a reason for hiding this comment

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

is this expected? What exactly is this test testing if these are errors?

Copy link
Member

Choose a reason for hiding this comment

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

or are these things we should put on our TODO list to fix?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this should go in a TODO list to fix. The idea behind it is that if the ppx creates the AST in a way that this tests pass, we should never have any more problems with editor not finding locations, getting confused about types on hover, etc, as the tree would be consistent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Rather than having to write "manual" tests in a per-case basis like in #842.

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 this pull request may close these issues.

3 participants