Skip to content

Improve error messages for function calls with mismatching args #7055

Open
@zth

Description

@zth

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, ...)`.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Ready

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions