mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-26 03:12:07 -05:00
LibJS: Allow "for" statement without curly braces around body
This commit is contained in:
parent
42f47da75d
commit
9c8363bb5f
2 changed files with 15 additions and 1 deletions
|
@ -810,7 +810,7 @@ NonnullRefPtr<ForStatement> Parser::parse_for_statement()
|
|||
|
||||
consume(TokenType::ParenClose);
|
||||
|
||||
auto body = parse_block_statement();
|
||||
auto body = parse_statement();
|
||||
|
||||
return create_ast_node<ForStatement>(move(init), move(test), move(update), move(body));
|
||||
}
|
||||
|
|
14
Libraries/LibJS/Tests/for-no-curlies.js
Normal file
14
Libraries/LibJS/Tests/for-no-curlies.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var number = 0;
|
||||
|
||||
for (var i = 0; i < 3; ++i)
|
||||
for (var j = 0; j < 3; ++j)
|
||||
number++;
|
||||
|
||||
assert(number === 9);
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Reference in a new issue