Fix unreachable code heuristic for conditionals

This commit is contained in:
Rerumu 2022-06-12 04:38:28 -04:00
parent 735dfc7d96
commit c15a4b3ec7

View File

@ -515,12 +515,18 @@ impl<'a> Builder<'a> {
Instruction::Block(_) | Instruction::Loop(_) | Instruction::If(_) => { Instruction::Block(_) | Instruction::Loop(_) | Instruction::If(_) => {
self.nested_unreachable += 1; self.nested_unreachable += 1;
} }
Instruction::End => { Instruction::Else if self.nested_unreachable == 1 => {
self.nested_unreachable -= 1;
self.start_else();
}
Instruction::End if self.nested_unreachable == 1 => {
self.nested_unreachable -= 1; self.nested_unreachable -= 1;
if self.nested_unreachable == 0 {
self.end_block(); self.end_block();
} }
Instruction::End => {
self.nested_unreachable -= 1;
} }
_ => {} _ => {}
} }