Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1107)

Unified Diff: src/parsing/parser.cc

Issue 2034653002: Fix bug in yield* desugaring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/harmony/iterator-close.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 83f9f7cbae7c0a0f910548fa56990cc19337bc5a..5f6d460d5468cf5d1271dece71cfa3353b3e5fcf 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -6421,12 +6421,18 @@ void ParserTraits::BuildIteratorClose(ZoneList<Statement*>* statements,
// following code:
//
// let iteratorReturn = iterator.return;
- // if (IS_NULL_OR_UNDEFINED(iteratorReturn) return |input|;
- // output = %_Call(iteratorReturn, iterator|, input|);
+ // if (IS_NULL_OR_UNDEFINED(iteratorReturn) {
+ // return {value: input, done: true};
+ // }
+ // output = %_Call(iteratorReturn, iterator, input);
// if (!IS_RECEIVER(output)) %ThrowIterResultNotAnObject(output);
//
- // Here, |...| denotes optional parts, depending on the presence of the
- // input variable. The reason for allowing input is that BuildIteratorClose
+ // When the input variable is not given, the return statement becomes
+ // return {value: undefined, done: true};
+ // and %_Call has only two arguments:
+ // output = %_Call(iteratorReturn, iterator);
+ //
+ // The reason for allowing input is that BuildIteratorClose
// can then be reused to handle the return case in yield*.
//
@@ -6450,7 +6456,9 @@ void ParserTraits::BuildIteratorClose(ZoneList<Statement*>* statements,
get_return = factory->NewExpressionStatement(assignment, nopos);
}
- // if (IS_NULL_OR_UNDEFINED(iteratorReturn) return |input|;
+ // if (IS_NULL_OR_UNDEFINED(iteratorReturn) {
+ // return {value: input, done: true};
+ // }
Statement* check_return;
{
Expression* condition = factory->NewCompareOperation(
@@ -6462,13 +6470,14 @@ void ParserTraits::BuildIteratorClose(ZoneList<Statement*>* statements,
factory->NewVariableProxy(input.FromJust()))
: factory->NewUndefinedLiteral(nopos);
- Statement* return_input = factory->NewReturnStatement(value, nopos);
+ Statement* return_input =
+ factory->NewReturnStatement(BuildIteratorResult(value, true), nopos);
check_return = factory->NewIfStatement(
condition, return_input, factory->NewEmptyStatement(nopos), nopos);
}
- // output = %_Call(iteratorReturn, iterator, |input|);
+ // output = %_Call(iteratorReturn, iterator, input);
Statement* call_return;
{
auto args = new (zone) ZoneList<Expression*>(3, zone);
« no previous file with comments | « no previous file | test/mjsunit/harmony/iterator-close.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698