Commit e7cd9d32 authored by wingo's avatar wingo Committed by Commit bot

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

Thanks to André Bargull for the report.

BUG=v8:4212
LOG=N
R=rossberg@chromium.org

Review URL: https://codereview.chromium.org/1309523005

Cr-Commit-Position: refs/heads/master@{#30381}
parent b4c73994
......@@ -2934,6 +2934,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());
......
......@@ -3801,6 +3801,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] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment