Commit 967a0463 authored by adamk's avatar adamk Committed by Commit bot

Forward accept_IN to ParseYieldExpression

This allows "yield 'x' in o" as an expression in a generator.

R=ishell@chromium.org
BUG=v8:4945
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#35798}
parent 2158df87
......@@ -773,7 +773,8 @@ class ParserBase : public Traits {
ExpressionT ParseAssignmentExpression(bool accept_IN,
ExpressionClassifier* classifier,
bool* ok);
ExpressionT ParseYieldExpression(ExpressionClassifier* classifier, bool* ok);
ExpressionT ParseYieldExpression(bool accept_IN,
ExpressionClassifier* classifier, bool* ok);
ExpressionT ParseConditionalExpression(bool accept_IN,
ExpressionClassifier* classifier,
bool* ok);
......@@ -1896,7 +1897,7 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
int lhs_beg_pos = peek_position();
if (peek() == Token::YIELD && is_generator()) {
return this->ParseYieldExpression(classifier, ok);
return this->ParseYieldExpression(accept_IN, classifier, ok);
}
FuncNameInferrer::State fni_state(fni_);
......@@ -2043,7 +2044,8 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
template <class Traits>
typename ParserBase<Traits>::ExpressionT
ParserBase<Traits>::ParseYieldExpression(ExpressionClassifier* classifier,
ParserBase<Traits>::ParseYieldExpression(bool accept_IN,
ExpressionClassifier* classifier,
bool* ok) {
// YieldExpression ::
// 'yield' ([no line terminator] '*'? AssignmentExpression)?
......@@ -2073,7 +2075,7 @@ ParserBase<Traits>::ParseYieldExpression(ExpressionClassifier* classifier,
if (!delegating) break;
// Delegating yields require an RHS; fall through.
default:
expression = ParseAssignmentExpression(false, classifier, CHECK_OK);
expression = ParseAssignmentExpression(accept_IN, classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK);
break;
}
......
......@@ -2395,6 +2395,10 @@ TEST(ErrorsYieldGenerator) {
"var {foo: yield 24} = {a: 42};",
"[yield 24] = [42];",
"({a: yield 24} = {a: 42});",
"for (yield 'x' in {});",
"for (yield 'x' of {});",
"for (yield 'x' in {} in {});",
"for (yield 'x' in {} of {});",
NULL
};
// clang-format on
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function* g(o) {
yield 'x' in o;
}
assertTrue(g({x: 1}).next().value);
assertFalse(g({}).next().value);
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