Skip to content

Commit 4fd57cf

Browse files
authored
flambda-backend: Use ghost loc for extension to avoid expressions with overlapping locations (#399)
1 parent 8d993c5 commit 4fd57cf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

parsing/extensions.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ let structure_item_of_expr ~loc expr =
4343
pstr_loc=loc;
4444
}
4545

46-
let map_comprehension ~loc extension_name body comp_list : extension=
46+
let map_comprehension ~loc:orig_loc extension_name body comp_list : extension =
47+
let loc = { orig_loc with Location.loc_ghost = true } in
4748
(*This is unreachable and just used as a place holder.*)
4849
let unreachable =
4950
{
@@ -86,7 +87,7 @@ let map_comprehension ~loc extension_name body comp_list : extension=
8687
) comp_list
8788
in
8889
let payload = PStr((structure_item_of_expr ~loc body)::list) in
89-
{ txt=extension_name; loc; }, payload
90+
{ txt=extension_name; loc=orig_loc; }, payload
9091

9192
let unwrap_expression ~loc = function
9293
| Pstr_eval(exp, _) -> exp
@@ -162,7 +163,7 @@ let report_error ~loc = function
162163
| Extension_not_existent extension_name ->
163164
Location.errorf ~loc "Extension %s does not exsist." extension_name
164165
| Illegal_comprehension_extension_construct ->
165-
Location.errorf ~loc "Wrong extension sytax for comprehensions."
166+
Location.errorf ~loc "Wrong extension syntax for comprehensions."
166167

167168
let () =
168169
Location.register_error_of_exn

0 commit comments

Comments
 (0)