-
Notifications
You must be signed in to change notification settings - Fork 100
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
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?
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
|
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 ? |
Given these are errors we produce ourselves and they point to an actual file, I guess we could directly have those errors point to line 1. Maybe we can factor this out in an internal How does that sound? |
That being said, I'm not particularly against using the matching compiler's |
b7784c3
to
b6943e2
Compare
@NathanReb -- as we discussed, since ppxlib only supports compilers 4.08+ we no longer need to handle multiple possible values for |
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.
Perfect, thanks!
I also think it's acceptable to bet on Location.none
not changing again. If it does we can experiment with the other suggestions, e.g. migrating Location.none
between versions or have Location.is_none
accept a range of representations.
Location.none has been changed to match the compiler's Location.none as of OCaml 4.08 which has been stable for some time. Since ppxlib only supports compilers greater than or equal to 4.08 we do not need to handle other possible none location values. Signed-off-by: Patrick Ferris <[email protected]>
Signed-off-by: Patrick Ferris <[email protected]>
b6943e2
to
f8c8650
Compare
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.