Skip to content

Improve error message for missing label(s) in function application #6576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
- Fixed issue with coercions sometimes raising a `Not_found` instead of giving a proper error message. https://github.com/rescript-lang/rescript-compiler/pull/6574
- Fix issue with recursive modules and uncurried. https://github.com/rescript-lang/rescript-compiler/pull/6575

#### :nail_care: Polish

- Improve error message for missing label(s) in function application. https://github.com/rescript-lang/rescript-compiler/pull/6576

# 11.0.0

No changes compared to rc.9.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

We've found a bug for you!
/.../fixtures/missing_label.res:3:9

1 │ let f = (~a) => a ++ ""
2 │
3 │ let _ = f("")
4 │

Label ~a was omitted in the application of this labeled function.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

We've found a bug for you!
/.../fixtures/missing_labels.res:3:9

1 │ let f = (~a, ~b) => a ++ b
2 │
3 │ let _ = f("", "")
4 │

Labels ~a, ~b were omitted in the application of this labeled function.
3 changes: 3 additions & 0 deletions jscomp/build_tests/super_errors/fixtures/missing_label.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let f = (~a) => a ++ ""

let _ = f("")
3 changes: 3 additions & 0 deletions jscomp/build_tests/super_errors/fixtures/missing_labels.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let f = (~a, ~b) => a ++ b

let _ = f("", "")
8 changes: 6 additions & 2 deletions jscomp/ml/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4056,9 +4056,13 @@ let report_error env ppf = function
| Illegal_letrec_pat ->
fprintf ppf
"Only variables are allowed as left-hand side of `let rec'"
| Labels_omitted [label] ->
fprintf ppf "Label ~%s was omitted in the application of this labeled function."
label
| Labels_omitted labels ->
fprintf ppf "For labeled function, labels %s were omitted in the application of this function."
(String.concat ", " labels)
let labelsString = labels |> List.map(fun label -> "~" ^ label) |> String.concat ", " in
fprintf ppf "Labels %s were omitted in the application of this labeled function."
labelsString
| Empty_record_literal ->
fprintf ppf "Empty record literal {} should be type annotated or used in a record context."
| Uncurried_arity_mismatch (typ, arity, args) ->
Expand Down