mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-30 02:33:38 +00:00
[wgsl] limit allowed for statement initializer statements
This commit is contained in:
parent
e49910bb0a
commit
9f113bdd95
@ -62,6 +62,8 @@ pub enum Error<'a> {
|
||||
BadTypeCast(&'a str),
|
||||
#[error(transparent)]
|
||||
InvalidResolve(ResolveError),
|
||||
#[error("invalid statement {0:?}, expected {1}")]
|
||||
InvalidStatement(crate::Statement, &'a str),
|
||||
#[error("unknown import: `{0}`")]
|
||||
UnknownImport(&'a str),
|
||||
#[error("unknown storage class: `{0}`")]
|
||||
@ -1816,7 +1818,19 @@ impl Parser {
|
||||
let initialization = if lexer.skip(Token::Separator(';')) {
|
||||
None
|
||||
} else {
|
||||
self.parse_statement(lexer, context.reborrow(), is_uniform_control_flow)?
|
||||
let statement =
|
||||
self.parse_statement(lexer, context.reborrow(), is_uniform_control_flow)?;
|
||||
match statement {
|
||||
Some(crate::Statement::Store { .. })
|
||||
| Some(crate::Statement::Call { .. }) => statement,
|
||||
Some(other) => {
|
||||
return Err(Error::InvalidStatement(
|
||||
other,
|
||||
"variable, assignment or function call",
|
||||
))
|
||||
}
|
||||
None => None,
|
||||
}
|
||||
};
|
||||
let condition = if lexer.skip(Token::Separator(';')) {
|
||||
None
|
||||
|
Loading…
Reference in New Issue
Block a user