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

Unified Diff: src/parsing/parser-base.h

Issue 2650863002: [parser] Throw error when there are too many excluded properties (Closed)
Patch Set: skip test in debug Created 3 years, 11 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/cctest/cctest.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index 57bfb69937cf012d3500abe0b63a90fdfc76543f..3f894e74f11d7aa61890b4a492591365209c93d6 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -2134,8 +2134,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePropertyName(
scanner()->location(),
MessageTemplate::kInvalidDestructuringTarget);
} else {
- // TODO(gsathya): Throw error if number of properties >
- // Code::kMaxArguments
CheckDestructuringElement(expression, pos,
scanner()->location().end_pos);
}
@@ -2595,6 +2593,16 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral(
// Computation of literal_index must happen before pre parse bailout.
int literal_index = function_state_->NextMaterializedLiteralIndex();
+ // In pattern rewriter, we rewrite rest property to call out to a
+ // runtime function passing all the other properties as arguments to
+ // this runtime function. Here, we make sure that the number of
+ // properties is less than number of arguments allowed for a runtime
+ // call.
+ if (has_rest_property && properties->length() > Code::kMaxArguments) {
+ this->classifier()->RecordPatternError(Scanner::Location(pos, position()),
+ MessageTemplate::kTooManyArguments);
+ }
+
return factory()->NewObjectLiteral(properties, literal_index,
number_of_boilerplate_properties, pos,
has_rest_property);
« no previous file with comments | « no previous file | test/cctest/cctest.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698