[glsl-in] Avoid infinite loop when parsing invalid statements (#1280)

This commit is contained in:
fsh authored and Dzmitry Malyshau committed 2021-09-01 16:46:46 -04:00
1 parent c722da8ac3
commit d08055151a
1 file changed
+5 -12
+5 -12
View File
@@ -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)))