unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.81k stars 271 forks source link

Bad error message on case-match with mismatched return type #5283

Open ChrisPenner opened 3 months ago

ChrisPenner commented 3 months ago

If an expression is annotated with a type, but the final expression is a case-match, we get a weird error message. E.g.:

x :  '{IO, Exception} Text
x  = do
  match 1 with
    1 -> 90
    _ -> 128

Will result in the following:

image
Each case of a match / with expression need to have the same type.

Here, one   is:  Text
and another is:  Nat

    4 |     1 -> 90

  from right here:

    1 | x :  '{IO, Exception} Text

This suggests there's a Text branch in the case, but actually that's just the annotated type.