mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
LibJS: Make missing variable decls in for..in/of a syntax error
...instead of a hard crash :P
This commit is contained in:
parent
e10006b3fa
commit
724b89f90c
1 changed files with 3 additions and 1 deletions
|
@ -1961,7 +1961,9 @@ NonnullRefPtr<Statement> Parser::parse_for_in_of_statement(NonnullRefPtr<ASTNode
|
|||
auto declarations = static_cast<VariableDeclaration&>(*lhs).declarations();
|
||||
if (declarations.size() > 1)
|
||||
syntax_error("multiple declarations not allowed in for..in/of");
|
||||
if (declarations.first().init() != nullptr)
|
||||
if (declarations.size() < 1)
|
||||
syntax_error("need exactly one variable declaration in for..in/of");
|
||||
else if (declarations.first().init() != nullptr)
|
||||
syntax_error("variable initializer not allowed in for..in/of");
|
||||
}
|
||||
auto in_or_of = consume();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue