Skip to content

Commit

Permalink
Externalize included_in for location overlapping
Browse files Browse the repository at this point in the history
  • Loading branch information
xvw committed Apr 12, 2024
1 parent 86e76b3 commit df12650
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/analysis/destruct.ml
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,8 @@ let rec get_every_pattern loc = function
begin
match
List.find_some ~f:(fun param ->
let open Location in
let param_loc = param.Typedtree.fp_loc in
Lexing.compare_pos loc.loc_start param_loc.loc_start >= 0
&& Lexing.compare_pos param_loc.loc_end loc.loc_end >= 0
) params with
Location_aux.included_in param.Typedtree.fp_loc loc
) params with
| Some pattern ->
(* In parameter case *)
collect_function_pattern loc pattern
Expand Down
4 changes: 4 additions & 0 deletions src/ocaml/parsing/location_aux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ let compare_pos pos loc =
else
0

let included_in parent_loc child_loc =
Lexing.compare_pos child_loc.loc_start parent_loc.loc_start >= 0 &&
Lexing.compare_pos parent_loc.loc_end child_loc.loc_end >= 0

let union l1 l2 =
if l1 = Location.none then l2
else if l2 = Location.none then l1
Expand Down
4 changes: 4 additions & 0 deletions src/ocaml/parsing/location_aux.mli
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ val union : t -> t -> t
(** Like location_union, but keep loc_ghost'ness of first argument *)
val extend : t -> t -> t

(** [included_in parent child] returns [true] if [child] is included
in [parent]. Otherwise returns [false]. *)
val included_in : t -> t -> bool

(** Filter valid errors, log invalid ones *)
val prepare_errors : exn list -> Location.error list

Expand Down

0 comments on commit df12650

Please sign in to comment.