mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 05:55:13 +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
Notes:
sideshowbarker
2024-07-18 17:11:00 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/724b89f90c8 Pull-request: https://github.com/SerenityOS/serenity/pull/7579 Issue: https://github.com/SerenityOS/serenity/issues/7566 Reviewed-by: https://github.com/linusg
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
Reference in a new issue