Skip to content
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

Improve error messages for function calls with mismatching args #7055

Open
zth opened this issue Sep 27, 2024 · 0 comments
Open

Improve error messages for function calls with mismatching args #7055

zth opened this issue Sep 27, 2024 · 0 comments
Milestone

Comments

@zth
Copy link
Collaborator

zth commented Sep 27, 2024

Example:

let someFn = (unlabelled: int, ~labelled1, ~opt1=?) => {
  ignore(opt1)
  unlabelled+labelled1
}

let c1 = someFn(~labelled1=1)

Produces this error:

This uncurried function has type (int, ~labelled1: int, ~opt1: 'a=?) => int
  It is applied with 1 arguments but it requires 3.

This isn't very helpful. Instead of showing the type signature and the application # vs required # arguments, let's make a list that shows:

  • Any required (labelled) arguments missing, plus their type (?)
  • Any extra argument provided that the function doesn't take

We don't need to mention uncurried in v12+ either, since everything is now uncurried.

Example of how the above could look:

This function call is:
- missing the required argument `labelled1: int`
- missing an unlabelled argument of type `int`

Did you mean to partially apply the function? If so, add 3 trailing dots to the function call, like `someFunction(~someArg, ...)`.
@zth zth added this to the v12 milestone Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready
Development

No branches or pull requests

1 participant