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

Unified Diff: src/parsing/parser.cc

Issue 1900343002: More accurately record an end position for default parameters in arrows (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: nikolaos comments Created 4 years, 8 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/parsing/parser.h ('k') | test/mjsunit/regress/regress-4908.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 c2d32c0d94ee0ffd6f406b67259fab83c054d87d..6f9702947fe04ff081baa1d3acbe471f83e4975d 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -3827,16 +3827,9 @@ Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) {
return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot)));
}
-
void ParserTraits::ParseArrowFunctionFormalParameters(
- ParserFormalParameters* parameters, Expression* expr,
- const Scanner::Location& params_loc, bool* ok) {
- if (parameters->Arity() >= Code::kMaxArguments) {
- ReportMessageAt(params_loc, MessageTemplate::kMalformedArrowFunParamList);
- *ok = false;
- return;
- }
-
+ ParserFormalParameters* parameters, Expression* expr, int end_pos,
+ bool* ok) {
// ArrowFunctionFormals ::
// Binary(Token::COMMA, NonTailArrowFunctionFormals, Tail)
// Tail
@@ -3857,7 +3850,8 @@ void ParserTraits::ParseArrowFunctionFormalParameters(
DCHECK_EQ(binop->op(), Token::COMMA);
Expression* left = binop->left();
Expression* right = binop->right();
- ParseArrowFunctionFormalParameters(parameters, left, params_loc, ok);
+ int comma_pos = binop->position();
+ ParseArrowFunctionFormalParameters(parameters, left, comma_pos, ok);
if (!*ok) return;
// LHS of comma expression should be unparenthesized.
expr = right;
@@ -3894,11 +3888,7 @@ void ParserTraits::ParseArrowFunctionFormalParameters(
parser_->scope_, parameters->scope);
}
- // TODO(adamk): params_loc.end_pos is not the correct initializer position,
- // but it should be conservative enough to trigger hole checks for variables
- // referenced in the initializer (if any).
- AddFormalParameter(parameters, expr, initializer, params_loc.end_pos,
- is_rest);
+ AddFormalParameter(parameters, expr, initializer, end_pos, is_rest);
}
@@ -3927,9 +3917,15 @@ void ParserTraits::ParseArrowFunctionFormalParameterList(
Scanner::Location* duplicate_loc, bool* ok) {
if (expr->IsEmptyParentheses()) return;
- ParseArrowFunctionFormalParameters(parameters, expr, params_loc, ok);
+ ParseArrowFunctionFormalParameters(parameters, expr, params_loc.end_pos, ok);
if (!*ok) return;
+ if (parameters->Arity() > Code::kMaxArguments) {
+ ReportMessageAt(params_loc, MessageTemplate::kMalformedArrowFunParamList);
+ *ok = false;
+ return;
+ }
+
Type::ExpressionClassifier classifier(parser_);
if (!parameters->is_simple) {
classifier.RecordNonSimpleParameter();
« no previous file with comments | « src/parsing/parser.h ('k') | test/mjsunit/regress/regress-4908.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698