Skip to content

Commit 8986037

Browse files
committed
labelled to optional arg
1 parent 9c27553 commit 8986037

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

compiler/ml/error_message_utils.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,12 @@ let print_extra_type_clash_help ~extract_concrete_typedecl ~env loc ppf
553553
| ( Some (FunctionArgument {optional = true}),
554554
Some ({desc = Tconstr (p, _, _)}, _) )
555555
when Path.same Predef.path_option p ->
556-
(* TODO(actions) Prepend with `?` *)
556+
Cmt_utils.add_possible_action
557+
{
558+
loc;
559+
action = RewriteArgType {to_type = `Optional};
560+
description = "Make argument optional";
561+
};
557562
fprintf ppf
558563
"@,\
559564
@,\
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
let myFunction = (~name: option<string>=?) => {
2+
ignore(name)
3+
}
4+
let name = Some("John")
5+
myFunction(~name?)
6+
7+
/* === AVAILABLE ACTIONS:
8+
- RewriteArgType(Optional) - Make argument optional
9+
*/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
let myFunction = (~name: option<string>=?) => {
2+
ignore(name)
3+
}
4+
let name = Some("John")
5+
myFunction(~name)

0 commit comments

Comments
 (0)