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

Unified Diff: src/preparser.h

Issue 1225223004: Fix spread array inside array literal (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add flag Created 5 years, 5 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 | « src/ast.cc ('k') | test/mjsunit/harmony/regress/regress-4298.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index 9f586469583c5cc7681c6a78c8f3d05b7b3ed260..177dc488fc9b5b404f4676a8107143544e675483 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -1175,6 +1175,11 @@ class PreParserFactory {
int pos) {
return PreParserExpression::Default();
}
+ PreParserExpression NewArrayLiteral(PreParserExpressionList values,
+ int first_spread_index, int literal_index,
+ bool is_strong, int pos) {
+ return PreParserExpression::Default();
+ }
PreParserExpression NewObjectLiteralProperty(PreParserExpression key,
PreParserExpression value,
ObjectLiteralProperty::Kind kind,
@@ -2388,6 +2393,7 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseArrayLiteral(
int pos = peek_position();
typename Traits::Type::ExpressionList values =
this->NewExpressionList(4, zone_);
+ int first_spread_index = -1;
Expect(Token::LBRACK, CHECK_OK);
while (peek() != Token::RBRACK) {
bool seen_spread = false;
@@ -2410,6 +2416,9 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseArrayLiteral(
this->ParseAssignmentExpression(true, classifier, CHECK_OK);
elem = factory()->NewSpread(argument, start_pos);
seen_spread = true;
+ if (first_spread_index < 0) {
+ first_spread_index = values->length();
+ }
} else {
elem = this->ParseAssignmentExpression(true, classifier, CHECK_OK);
}
@@ -2426,7 +2435,7 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseArrayLiteral(
// Update the scope information before the pre-parsing bailout.
int literal_index = function_state_->NextMaterializedLiteralIndex();
- return factory()->NewArrayLiteral(values, literal_index,
+ return factory()->NewArrayLiteral(values, first_spread_index, literal_index,
is_strong(language_mode()), pos);
}
« no previous file with comments | « src/ast.cc ('k') | test/mjsunit/harmony/regress/regress-4298.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698