rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

Confusing error message with mismatched optional labeled argument

Open glennsl opened this issue 1 year ago • 0 comments

let f: (~foo: int=?) => unit = (~foo) => ()

This yields the error:

This function should have type (~foo: int=?) => unit
  but its first argument is labelled ~foo

Seeing as the argument is labeled ~foo in both signature and implementation, the error message is a bit misleading. It should say that it should be optional.

Additionally, the error for the converse is this:

This function should have type (~foo: int) => unit
  but its first argument is labelled ?foo

which reveals OCaml syntax.

glennsl avatar Aug 09 '24 09:08 glennsl