Skip to content

Commit ce927e1

Browse files
committed
Improve error message for missing label(s) in function application
1 parent b2ae38a commit ce927e1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

jscomp/ml/typecore.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4056,9 +4056,13 @@ let report_error env ppf = function
40564056
| Illegal_letrec_pat ->
40574057
fprintf ppf
40584058
"Only variables are allowed as left-hand side of `let rec'"
4059+
| Labels_omitted [label] ->
4060+
fprintf ppf "Label ~%s was omitted in the application of this labeled function."
4061+
label
40594062
| Labels_omitted labels ->
4060-
fprintf ppf "For labeled function, labels %s were omitted in the application of this function."
4061-
(String.concat ", " labels)
4063+
let labelsString = labels |> List.map(fun label -> "~" ^ label) |> String.concat ", " in
4064+
fprintf ppf "Labels %s were omitted in the application of this labeled function."
4065+
labelsString
40624066
| Empty_record_literal ->
40634067
fprintf ppf "Empty record literal {} should be type annotated or used in a record context."
40644068
| Uncurried_arity_mismatch (typ, arity, args) ->

0 commit comments

Comments
 (0)