If a match contains a nested match where one or more cases return Never, the return type of the outer match is nil #865
Labels
accepting contributions
Issues that are suitable to be worked on by anybody, not just maintainers
bug
Defects, unintended behaviour, etc
compiler
Changes related to the compiler
Please describe the bug
The compiler has a feature where if one or more
case
branches in amatch
don't return a value, the values of othercase
branches are also ignored. This way you can write amatch
where one case does something that happens to return a value while anothercase
returnsnil
or breaks/returns, and you won't get a type error.It seems that for nested
match
expressions this isn't handled correctly as demonstrated by the following:This code should compile with
num
being a value ofInt
, but insteadnum
is typed asNil
and thus produces the following error:This is not the case if the inner
match
is replaced with just abreak
, so something goes wrong when dealing with nestedmatch
expressions.Operating system
Arch Linux
Inko version
main
The text was updated successfully, but these errors were encountered: