You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both the compiler and ppxlib define Location.none as let 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 defines dummy_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 the none-locationed attribute (e.g. a doc comment):
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: