mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-29 17:44:09 +01:00
[valid] Check that the last switch case isn't falltrough (#1485)
This commit is contained in:
1 parent
00bbbed90a
commit
0458f0a404
1 file changed
+13
@@ -108,6 +108,8 @@ pub enum FunctionError {
|
||||
ConflictingSwitchCase(i32),
|
||||
#[error("Multiple `default` cases are present")]
|
||||
MultipleDefaultCases,
|
||||
#[error("The last `switch` case contains a `falltrough`")]
|
||||
LastCaseFallTrough,
|
||||
#[error("The pointer {0:?} doesn't relate to a valid destination for a store")]
|
||||
InvalidStorePointer(Handle<crate::Expression>),
|
||||
#[error("The value {0:?} can not be stored")]
|
||||
@@ -469,6 +471,17 @@ impl super::Validator {
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(case) = cases.last() {
|
||||
if case.fall_through {
|
||||
return Err(FunctionError::LastCaseFallTrough.with_span_static(
|
||||
case.body
|
||||
.span_iter()
|
||||
.next()
|
||||
.map_or(Default::default(), |(_, s)| *s),
|
||||
"bad switch arm here",
|
||||
));
|
||||
}
|
||||
}
|
||||
let pass_through_abilities = context.abilities
|
||||
& (ControlFlowAbility::RETURN | ControlFlowAbility::CONTINUE);
|
||||
let sub_context =
|
||||
|
||||
Reference in new issue
Block a user