From dc8a41de04068b4766c1e74f9d77f765e815172a Mon Sep 17 00:00:00 2001 From: Aleksi Sapon Date: Fri, 17 Sep 2021 16:54:48 -0400 Subject: [PATCH] spv-in: no case fallthrough when last statement allows it --- src/front/spv/function.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/front/spv/function.rs b/src/front/spv/function.rs index 8814bb59b4..90ea81033e 100644 --- a/src/front/spv/function.rs +++ b/src/front/spv/function.rs @@ -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(),