Index: test/cctest/test-parsing.cc |
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
index b4ee2cc6be5d55e539cf73f4f70fc9a51f42130e..36f729344f94e2fc931bfe43fa42f2d46cfcbb12 100644 |
--- a/test/cctest/test-parsing.cc |
+++ b/test/cctest/test-parsing.cc |
@@ -2015,25 +2015,28 @@ TEST(NoErrorsEvalAndArgumentsStrict) { |
RunParserSyncTest(context_data, statement_data, kSuccess); |
} |
+#define FUTURE_STRICT_RESERVED_WORDS_NO_LET(V) \ |
+ V(implements) \ |
+ V(interface) \ |
+ V(package) \ |
+ V(private) \ |
+ V(protected) \ |
+ V(public) \ |
+ V(static) \ |
+ V(yield) |
#define FUTURE_STRICT_RESERVED_WORDS(V) \ |
- V(implements) \ |
- V(interface) \ |
V(let) \ |
- V(package) \ |
- V(private) \ |
- V(protected) \ |
- V(public) \ |
- V(static) \ |
- V(yield) |
+ FUTURE_STRICT_RESERVED_WORDS_NO_LET(V) |
+#define LIMITED_FUTURE_STRICT_RESERVED_WORDS_NO_LET(V) \ |
+ V(implements) \ |
+ V(static) \ |
+ V(yield) |
#define LIMITED_FUTURE_STRICT_RESERVED_WORDS(V) \ |
- V(implements) \ |
V(let) \ |
- V(static) \ |
- V(yield) |
- |
+ LIMITED_FUTURE_STRICT_RESERVED_WORDS_NO_LET(V) |
#define FUTURE_STRICT_RESERVED_STATEMENTS(NAME) \ |
"var " #NAME ";", \ |
@@ -2049,25 +2052,52 @@ TEST(NoErrorsEvalAndArgumentsStrict) { |
"++" #NAME ";", \ |
#NAME " ++;", |
+// clang-format off |
+#define FUTURE_STRICT_RESERVED_LEX_BINDINGS(NAME) \ |
+ "let " #NAME ";", \ |
+ "for (let " #NAME "; false; ) {}", \ |
+ "for (let " #NAME " in {}) {}", \ |
+ "for (let " #NAME " of []) {}", \ |
+ "const " #NAME " = null;", \ |
+ "for (const " #NAME " = null; false; ) {}", \ |
+ "for (const " #NAME " in {}) {}", \ |
+ "for (const " #NAME " of []) {}", |
+// clang-format on |
TEST(ErrorsFutureStrictReservedWords) { |
// Tests that both preparsing and parsing produce the right kind of errors for |
// using future strict reserved words as identifiers. Without the strict mode, |
// it's ok to use future strict reserved words as identifiers. With the strict |
// mode, it isn't. |
- const char* context_data[][2] = { |
+ const char* strict_contexts[][2] = { |
{"function test_func() {\"use strict\"; ", "}"}, |
{"() => { \"use strict\"; ", "}"}, |
{NULL, NULL}}; |
+ // clang-format off |
const char* statement_data[] { |
LIMITED_FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_STATEMENTS) |
+ LIMITED_FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_LEX_BINDINGS) |
NULL |
}; |
+ // clang-format on |
- RunParserSyncTest(context_data, statement_data, kError); |
-} |
+ RunParserSyncTest(strict_contexts, statement_data, kError); |
+ // From ES2015, 13.3.1.1 Static Semantics: Early Errors: |
+ // |
+ // > LexicalDeclaration : LetOrConst BindingList ; |
+ // > |
+ // > - It is a Syntax Error if the BoundNames of BindingList contains "let". |
+ const char* non_strict_contexts[][2] = {{"", ""}, |
+ {"function test_func() {", "}"}, |
+ {"() => {", "}"}, |
+ {NULL, NULL}}; |
+ const char* invalid_statements[] = {FUTURE_STRICT_RESERVED_LEX_BINDINGS("let") |
+ NULL}; |
+ |
+ RunParserSyncTest(non_strict_contexts, invalid_statements, kError); |
+} |
#undef LIMITED_FUTURE_STRICT_RESERVED_WORDS |
@@ -2080,10 +2110,13 @@ TEST(NoErrorsFutureStrictReservedWords) { |
{ NULL, NULL } |
}; |
+ // clang-format off |
const char* statement_data[] = { |
FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_STATEMENTS) |
+ FUTURE_STRICT_RESERVED_WORDS_NO_LET(FUTURE_STRICT_RESERVED_LEX_BINDINGS) |
NULL |
}; |
+ // clang-format on |
RunParserSyncTest(context_data, statement_data, kSuccess); |
} |