summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Libraries/LibJS/Parser.cpp2
-rw-r--r--Libraries/LibJS/Tests/for-no-curlies.js14
2 files changed, 15 insertions, 1 deletions
diff --git a/Libraries/LibJS/Parser.cpp b/Libraries/LibJS/Parser.cpp
index d9d1cbd7a4..6541f51fc0 100644
--- a/Libraries/LibJS/Parser.cpp
+++ b/Libraries/LibJS/Parser.cpp
@@ -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));
}
diff --git a/Libraries/LibJS/Tests/for-no-curlies.js b/Libraries/LibJS/Tests/for-no-curlies.js
new file mode 100644
index 0000000000..817aea2fbb
--- /dev/null
+++ b/Libraries/LibJS/Tests/for-no-curlies.js
@@ -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);
+}