-
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
Location.none
is different than the compiler's
#532
Comments
Thanks @ncik-roberts ! I'll run this through some reverse dependency checks to see if anything comes up but I think we could align with the compiler's values. |
Hey @ncik-roberts, Whilst writing some tests for this portion of code I was wondering under which circumstances you ran into this issue -- it seems to be fairly hard to trigger given most of the checks against |
Yes, I think it's simply that a user ppx was calling the
The |
Thanks @ncik-roberts ! I hadn't clocked that |
Both the compiler and ppxlib define
Location.none
aslet pos = { dummy_pos with pos_fname = "_none_" } in { loc_start = pos; loc_end = pos; loc_ghost = true }
.However, ppxlib defines
dummy_pos
as{ pos_fname = ...; pos_lnum = 1; pos_bol = 0; pos_cnum = -1 }
1, whereas the compiler definesdummy_pos
as{ pos_fname = ...; pos_lnum = 0; pos_bol = 0; pos_cnum = -1 }
2.pos_lnum
is different.This mismatch causes at least 1 bug in ppxlib. For example, this code that attempts to show a reasonable location in the event that an attribute's location is
none
will fail to detect the case where the compiler inserted thenone
-locationed attribute (e.g. a doc comment):ppxlib/src/common.ml
Lines 146 to 157 in 8a0cb71
At Jane Street, we've patched ppxlib's
Location.none
to be the same as the compiler's with no issues.Footnotes
https://github.com/ocaml-ppx/ppxlib/blob/8a0cb7122d7d454c20d732621795d910018d1b66/src/location.ml#L10-L19 ↩
https://github.com/ocaml/ocaml/blob/b8f23dd5af09a3d9e6f891e2ac7f0d4baee81e1b/stdlib/lexing.ml#L25-L30 ↩
The text was updated successfully, but these errors were encountered: