OR patterns result in missing register states
When using an OR pattern in a match
expression, the compiler isn't able to find the state of certain registers. For example:
class async Main {
fn async main {
let bytes = ByteArray.new
while bytes.length > 0 {
match bytes[0] {
case 1 or 2 -> bytes.remove_at(0)
case _ -> 0
}
}
}
}
Running this code in debug mode results in this panic:
thread 'main' panicked at 'missing state for register r14 in block b5 (method "main" in "/tmp/test.inko")', compiler/src/mir/passes.rs:4244:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
This was found while I was playing around with https://rosettacode.org/wiki/Chat_server in an attempt to find any more obvious bugs. As part of that experiment I ended up hacking together whitespace stripping using a match
, which led me to this error.