Skip to content

Commit

Permalink
spv-in: no case fallthrough when last statement allows it
Browse files Browse the repository at this point in the history
  • Loading branch information
DDoS authored and JCapucho committed Sep 20, 2021
1 parent 60d0bf8 commit dc8a41d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/front/spv/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,19 @@ impl<'function> BlockContext<'function> {
.map(|&(value, body_idx)| {
let body = lower_impl(blocks, bodies, body_idx);

// Handle simple cases that would make a fallthrough statement unreachable code
let fall_through = match body.last() {
Some(&crate::Statement::Break)
| Some(&crate::Statement::Continue)
| Some(&crate::Statement::Kill)
| Some(&crate::Statement::Return { .. }) => false,
_ => true,
};

crate::SwitchCase {
value,
body,
// TODO
fall_through: true,
fall_through,
}
})
.collect(),
Expand Down

0 comments on commit dc8a41d

Please sign in to comment.