-
Notifications
You must be signed in to change notification settings - Fork 99
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
Match compilers dummy loc #540
base: main
Are you sure you want to change the base?
Match compilers dummy loc #540
Conversation
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.
Looks good to me!
This probably needs a changelog entry!
Seems some tests need to be updated as well! |
Also, rebasing it will reduce the diff as the quoter tests don't print out the whole AST anymore! |
a4e858c
to
4aad4e6
Compare
Turns out this actually changed in OCaml compiler versions, so this is not the proper fix.
The fix might be fairly easy (using Cinaps) but the problem becomes all of the expect tests. And whilst we could in theory do the |
I guess we could use [%%ignore] here, similar to what I did for the let x = [%expr ...]
[%%ignore]
let () = Pp_ast.Default.expression x
[%%expect {|
...
|}] Would that work for you? |
5936109
to
0549bd1
Compare
It actually turns out I don't need that @NathanReb -- the files are only enabled for new enough compilers that it doesn't matter. But it is good to have that trick up my sleeve should we need it. Happy to make that change here to help future proof these tests (but I don't think it is likely for those bits to change too much). |
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.
If I understood the issue correctly, the important part is to agree with the compiler on what is Location.none
right?
If so then we could probably simply stick to using the compiler's functions to build none
locs.
This won't work when reading AST emitted by a different compiler (which we in theory support) but even that could be fixed by versioning the none loc.
As I'm writing this I wonder if the right fix isn't the following:
- Stick to having our stable
Location.none
and choose a convention for it - Have a function that detects whether a location is a valid
none
loc from any version we support - Use the function from
2
instead of poly=
in our codebase
What do you think?
139d7e1
to
dfd2058
Compare
Location.none has been changed to match the compiler's Location.none as of OCaml 4.08. This has been stable for some time. We also provide a Location.is_none which checks if a location is equal to Location.none for all versions of the compiler we currently support (i.e. >= 4.04). The decision to change Location.none has been made to enable the code to be simplified if we decide to change the lower bound of ppxlib to 4.08 in the future. Location.is_none has been used to fix loc_of_attribute which would sometimes miss attributes with none locations (like compiler inserted ocaml.doc attributes). Signed-off-by: Patrick Ferris <[email protected]>
dfd2058
to
2a158e9
Compare
After some discussion with @NathanReb this PR now does the following:
The decision to change Location.none has been made to enable the code to
|
Signed-off-by: Patrick Ferris <[email protected]>
The current errors we're seeing on 4.04 and 4.05 are due to newer compiler versions checking of a line number is "valid" or not (i.e. On the older compilers, the location is used directly, hence we are getting
any thoughts @NathanReb ? |
A fix as per #532.
I tested reverse dependencies (I think most of them, for their latest version) and they mostly installed
--with-test
. Any that didn't seemed unrelated.