jakt
jakt copied to clipboard
Typechecker: Matchings that yield optionals cannot infer the type of `None`
The following code fails to compile, because the typechecker does not know how to handle None
here.
function foo() -> bool? => match 0 {
1 => false
else => None
}
function main() {
let a = foo()
}
The error (in which the types are flipped, but that's for another issue :^) ) is
Error: Type mismatch: expected ‘unknown’, but got ‘bool’
10 | false => false
11 | else => None
^- Type mismatch: expected ‘unknown’, but got ‘bool’
12 | }
-----
Hey there! I'd like to take a look into this. I'll reach out on discord with any questions I have.
fixed as of 1ea81c6. filed #1139 as a follow up for type inference.