Skip to content

Commit

Permalink
[B] ocaml#1807 Check always that default args are option
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Sep 25, 2024
1 parent f24206c commit 5cd475b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ unreleased
- A new `WRAPPING_PREFIX` configuration directive that can be used to tell Merlin
what to append to the current unit name in the presence of wrapping (#1788)
- Add `-unboxed-types` and `-no-unboxed-types` as ocaml ignored flags (#1795, fixes #1794)
- destruct: Refinement in the presence of optional arguments (#1800 fixes #1770)
- destruct: Refinement in the presence of optional arguments (#1800 #1807, fixes #1770)
+ editor modes
- vim: fix python-3.12 syntax warnings in merlin.py (#1798)
- vim: Dead code / doc removal for previously deleted MerlinPhrase command (#1804)
Expand Down
19 changes: 8 additions & 11 deletions src/analysis/destruct.ml
Original file line number Diff line number Diff line change
Expand Up @@ -573,19 +573,16 @@ let remove_non_applied_optional_args (Parsetree.{ pexp_desc; _} as base_expr) =
https://github.com/ocaml/merlin/issues/1770 *)
match pexp_desc with
| Parsetree.Pexp_apply (expr, args) ->
let args = List.concat_map ~f:(fun (label, expr) ->
match label with
| Asttypes.Optional str ->
(* If an optional parameter is not applied, its location is assumed to
be ghost, and the parameter should not be generated. *)
let loc = expr.Parsetree.pexp_loc in
if loc.loc_ghost
then []
else begin
match need_recover_labeled_args expr.pexp_desc with
let args = List.concat_map ~f:(fun (label, (expr : Parsetree.expression)) ->
match label, expr.pexp_loc.loc_ghost, expr.pexp_desc with
| Asttypes.Optional _, true,
Pexp_construct ({ txt = Longident.Lident "None"; _ }, _) ->
[]
| Asttypes.Optional str, false, exp_desc ->
(match need_recover_labeled_args exp_desc with
| Some e -> [(Asttypes.Labelled str, e)]
| None -> [(label, expr)]
end
)
| _ -> [(label, expr)]
) args
in
Expand Down

0 comments on commit 5cd475b

Please sign in to comment.