mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 22:11:01 +01:00
[glsl-in] Avoid infinite loop when parsing invalid statements (#1280)
This commit is contained in:
1 parent
c722da8ac3
commit
d08055151a
1 file changed
+5
-12
@@ -490,23 +490,16 @@ impl<'source> ParsingContext<'source> {
|
||||
|
||||
meta
|
||||
}
|
||||
TokenValue::Plus
|
||||
| TokenValue::Dash
|
||||
| TokenValue::Bang
|
||||
| TokenValue::Tilde
|
||||
| TokenValue::LeftParen
|
||||
| TokenValue::Identifier(_)
|
||||
| TokenValue::TypeName(_)
|
||||
| TokenValue::IntConstant(_)
|
||||
| TokenValue::BoolConstant(_)
|
||||
| TokenValue::FloatConstant(_) => {
|
||||
TokenValue::Semicolon => self.bump(parser)?.meta,
|
||||
_ => {
|
||||
// Attempt to force expression parsing for remainder of the
|
||||
// tokens. Unknown or invalid tokens will be caught there and
|
||||
// turned into an error.
|
||||
let mut stmt = ctx.stmt_ctx();
|
||||
let expr = self.parse_expression(parser, ctx, &mut stmt, body)?;
|
||||
ctx.lower(stmt, parser, expr, false, body)?;
|
||||
self.expect(parser, TokenValue::Semicolon)?.meta
|
||||
}
|
||||
TokenValue::Semicolon => self.bump(parser)?.meta,
|
||||
_ => meta,
|
||||
};
|
||||
|
||||
Ok(Some(meta.union(&meta_rest)))
|
||||
|
||||
Reference in new issue
Block a user