Skip to content

Commit

Permalink
Fix changed and rewording
Browse files Browse the repository at this point in the history
  • Loading branch information
xvw committed Mar 5, 2024
1 parent 00807ff commit bc52339
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ merlin NEXT_VERSION

+ merlin binary
- destruct: Removal of residual patterns (#1737, fixes #1560)
- Reconstruction of the record field in the event of destruction on a record punning field
(#1734, fixes #1661)
- Do not erase fields' names when destructing punned record fields (#1734,
fixes #1661)

merlin 4.14
===========
Expand Down
14 changes: 7 additions & 7 deletions src/analysis/destruct.ml
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ let find_branch patterns sub =
(* In the presence of record punning fields, the definition must be reconstructed
with the label. ie: [{a; b}] with destruction on [a] becomes *)
(* [{a = destruct_result; b}]. *)
let find_field_name_for_punning_field patt = function
let find_field_name_for_punned_field patt = function
| Pattern {pat_desc = Tpat_record (fields, _); _} :: _ ->
List.find_opt ~f:(fun (_, _, opat) ->
let ppat_loc = patt.Typedtree.pat_loc
Expand All @@ -493,9 +493,9 @@ let find_field_name_for_punning_field patt = function
) fields |> Option.map ~f:(fun (_, label, _) -> label)
| _ -> None

let print_pretty ?punning_field config source subject =
let print_pretty ?punned_field config source subject =
let result = Mreader.print_pretty config source subject in
match punning_field with
match punned_field with
| None -> result
| Some label ->
label.Types.lbl_name ^ " = " ^ result
Expand Down Expand Up @@ -590,9 +590,9 @@ let rec node config source selected_node parents =
| [ more_precise ] ->
(* If only one pattern is generated, then we're only refining the
current pattern, not generating new branches. *)
let punning_field = find_field_name_for_punning_field patt parents in
let punned_field = find_field_name_for_punned_field patt parents in
let ppat = filter_pat_attr (Untypeast.untype_pattern more_precise) in
let str = print_pretty ?punning_field config source (Pretty_pattern ppat) in
let str = print_pretty ?punned_field config source (Pretty_pattern ppat) in
patt.Typedtree.pat_loc, str
| sub_patterns ->
let rev_before, after, top_patt =
Expand Down Expand Up @@ -631,8 +631,8 @@ let rec node config source selected_node parents =

(* Format.eprintf "ppor %a \n%!" (Pprintast.pattern) ppat; *)
let str = Mreader.print_pretty config source (Pretty_pattern ppat) in
(* Format.eprintf "STR: %s \n %!" str; *)
top_patt.Typedtree.pat_loc, str
(* Format.eprintf "STR: %s \n %!" str; *)
top_patt.Typedtree.pat_loc, str
end
end
end
Expand Down

0 comments on commit bc52339

Please sign in to comment.