diff --git a/CHANGES.md b/CHANGES.md index 504061516..f522320c4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 =========== diff --git a/src/analysis/destruct.ml b/src/analysis/destruct.ml index a07b2770c..fd5fafceb 100644 --- a/src/analysis/destruct.ml +++ b/src/analysis/destruct.ml @@ -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 @@ -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 @@ -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 = @@ -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