Reviewers: rossberg,

Description:
In generators, "yield" cannot be an arrow formal parameter name

Thanks to André Bargull for the report.

BUG=4212
LOG=N
[email protected]

Please review this at https://codereview.chromium.org/1309523005/

Base URL: https://chromium.googlesource.com/v8/v8@master

Affected files (+45, -0 lines):
  M src/preparser.h
  M test/cctest/test-parsing.cc


Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index f8f20e530aa18d2f7e4c8c1d892470d33dc662c6..bfbe4149174d1f077357497e8868acadead63c5c 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -2935,6 +2935,7 @@ ParserBase<Traits>::ParseYieldExpression(ExpressionClassifier* classifier,
   // YieldExpression ::
   //   'yield' ([no line terminator] '*'? AssignmentExpression)?
   int pos = peek_position();
+  BindingPatternUnexpectedToken(classifier);
   Expect(Token::YIELD, CHECK_OK);
   ExpressionT generator_object =
factory()->NewVariableProxy(function_state_->generator_object_variable());
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index 19ca85a13bd75649ee1d26297a73a0f4394e10bb..ef18bb737f5c9495e6cde721ce442c949fe062f1 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -3822,6 +3822,50 @@ TEST(ArrowFunctionsSloppyParameterNames) {
 }


+TEST(ArrowFunctionsYieldParameterNameInGenerator) {
+  const char* sloppy_function_context_data[][2] = {
+    {"(function f() { (", "); });"},
+    {NULL, NULL}
+  };
+
+  const char* strict_function_context_data[][2] = {
+    {"(function f() {'use strong'; (", "); });"},
+    {"(function f() {'use strict'; (", "); });"},
+    {NULL, NULL}
+  };
+
+  const char* generator_context_data[][2] = {
+    {"(function *g() {'use strong'; (", "); });"},
+    {"(function *g() {'use strict'; (", "); });"},
+    {"(function *g() { (", "); });"},
+    {NULL, NULL}
+  };
+
+  const char* arrow_data[] = {
+    "yield => {}",
+    "(yield) => {}",
+    "(a, yield) => {}",
+    "(yield, a) => {}",
+    "(yield, ...a) => {}",
+    "(a, ...yield) => {}",
+    "({yield}) => {}",
+    "([yield]) => {}",
+    NULL
+  };
+
+  static const ParserFlag always_flags[] = { kAllowHarmonyDestructuring,
+                                             kAllowHarmonyRestParameters,
+                                             kAllowHarmonyArrowFunctions,
+                                             kAllowStrongMode};
+ RunParserSyncTest(sloppy_function_context_data, arrow_data, kSuccess, NULL, 0,
+                    always_flags, arraysize(always_flags));
+ RunParserSyncTest(strict_function_context_data, arrow_data, kError, NULL, 0,
+                    always_flags, arraysize(always_flags));
+  RunParserSyncTest(generator_context_data, arrow_data, kError, NULL, 0,
+                    always_flags, arraysize(always_flags));
+}
+
+
 TEST(SuperNoErrors) {
// Tests that parser and preparser accept 'super' keyword in right places.
   const char* context_data[][2] = {


--
--
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.

Reply via email to