syntax icon indicating copy to clipboard operation
syntax copied to clipboard

Consider having a more helpful error-message for `option<'a>`

Open lessp opened this issue 5 years ago • 0 comments

I see this trip up a lot of newcomers, especially with the generic 'a.

This pattern matches values of type option<'a>
but a pattern was expected which matches values of type foo

Is it possible to show `option? Alternatively perhaps give a more specific hint of what might be wrong? 🤷

Here's one example:

type foo = {bar: unit => unit}

external foo: unit => foo = "foo"

let x = foo()

switch x {
| Some(foo) => foo.bar()
| None => ()
}

Originally posted by @lessp in https://github.com/rescript-lang/syntax/issues/336#issuecomment-809559645

lessp avatar Mar 30 '21 02:03 lessp