Reviewers: marja,
Description:
Parser sync tests for `let` identifiers
[email protected]
BUG=
Please review this at https://codereview.chromium.org/385613002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+47, -5 lines):
M src/parser.cc
M test/cctest/test-parsing.cc
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index
6886fcca2a0419281270fcecc70c5e54a9307b0d..ddd76103ea5a02bf60d78e6c0d72bbe8fa94e97c
100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -2013,6 +2013,7 @@ Block* Parser::ParseVariableDeclarations(
is_const = true;
needs_init = true;
} else if (peek() == Token::LET && strict_mode() == STRICT) {
+ ASSERT(allow_harmony_scoping());
Consume(Token::LET);
if (var_context == kStatement) {
// Let declarations are only allowed in source element positions.
@@ -3052,6 +3053,7 @@ Statement* Parser::ParseForStatement(ZoneList<const
AstRawString*>* labels,
init = variable_statement;
}
} else if (peek() == Token::LET && strict_mode() == STRICT) {
+ ASSERT(allow_harmony_scoping());
const AstRawString* name = NULL;
VariableDeclarationProperties decl_props = kHasNoInitializers;
Block* variable_statement =
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index
d4fc206e76f48c482dc5a0317f9f5ae60595a198..0ce2b2c41e74c4998ed17e2ce293363bea114eed
100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1749,9 +1749,45 @@ TEST(ErrorsReservedWords) {
}
+TEST(NoErrorsLetSloppyAllModes) {
+ // In sloppy mode, it's okay to use "let" as identifier.
+ const char* context_data[][2] = {
+ { "", "" },
+ { "function f() {", "}" },
+ { "(function f() {", "})" },
+ { NULL, NULL }
+ };
+
+ const char* statement_data[] = {
+ "var let;",
+ "var foo, let;",
+ "try { } catch (let) { }",
+ "function let() { }",
+ "(function let() { })",
+ "function foo(let) { }",
+ "function foo(bar, let) { }",
+ "let = 1;",
+ "var foo = let = 1;",
+ "let * 2;",
+ "++let;",
+ "let++;",
+ "let: 34",
+ "function let(let) { let: let(let + let(0)); }",
+ "({ let: 1 })",
+ "({ get let() { 1 } })",
+ "let(100)",
+ NULL
+ };
+
+ static const ParserFlag always_flags[] = {kAllowArrowFunctions};
+ RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
+ always_flags, ARRAY_SIZE(always_flags));
+}
+
+
TEST(NoErrorsYieldSloppyAllModes) {
// In sloppy mode, it's okay to use "yield" as identifier, *except*
inside a
- // generator (see next test).
+ // generator (see other test).
const char* context_data[][2] = {
{ "", "" },
{ "function not_gen() {", "}" },
@@ -1769,13 +1805,15 @@ TEST(NoErrorsYieldSloppyAllModes) {
"function foo(bar, yield) { }",
"yield = 1;",
"var foo = yield = 1;",
+ "yield * 2;",
"++yield;",
"yield++;",
"yield: 34",
- "function yield(yield) { yield: yield (yield + yield (0)); }",
+ "function yield(yield) { yield: yield (yield + yield(0)); }",
"({ yield: 1 })",
"({ get yield() { 1 } })",
- "yield (100)",
+ "yield(100)",
+ "yield[100]",
NULL
};
@@ -1809,13 +1847,15 @@ TEST(NoErrorsYieldSloppyGeneratorsEnabled) {
"(function * yield() { })",
"yield = 1;",
"var foo = yield = 1;",
+ "yield * 2;",
"++yield;",
"yield++;",
"yield: 34",
- "function yield(yield) { yield: yield (yield + yield (0)); }",
+ "function yield(yield) { yield: yield (yield + yield(0)); }",
"({ yield: 1 })",
"({ get yield() { 1 } })",
- "yield (100)",
+ "yield(100)",
+ "yield[100]",
NULL
};
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.