enso icon indicating copy to clipboard operation
enso copied to clipboard

Return type is not checked if it contains an error context (`!`)

Open radeusgd opened this issue 9 months ago • 0 comments

I just found out we forgot to handle ! in our type ascriptions. For arguments that wasn't really used (even if allowed), so it was OK, but once we started using the same logic in return type checks that started to cause problems - if you add ! to your return type ascription (which is a good practice from perspective of documentation), the type check gets disabled.

Repro:

from Standard.Base import all

type My_Error

f1 x -> Integer ! My_Error = x
f2 x -> Integer = x

main =
    IO.println (f1 42)
    IO.println (f2 42)
    IO.println (Panic.recover Any (f1 "txt"))
    IO.println (Panic.recover Any (f2 "txt"))

Actual behaviour

42
42
txt
(Error: Type error: expected the result of `f2` to be Integer, but got Text.)

Expected behaviour

42
42
(Error: Type error: expected the result of `f1` to be Integer, but got Text.)
(Error: Type error: expected the result of `f2` to be Integer, but got Text.)

radeusgd avatar May 17 '24 09:05 radeusgd