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

Unified Diff: src/parser.cc

Issue 329413002: Throw syntax error when a getter/setter has the wrong number of params (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add test exception Created 6 years, 6 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/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 51065568bac7855a841c4fc724ba1d60d5e633a1..98bf6f9507b387206cde8fb95211ba09f20a1126 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -752,10 +752,12 @@ FunctionLiteral* ParserTraits::ParseFunctionLiteral(
bool is_generator,
int function_token_position,
FunctionLiteral::FunctionType type,
+ FunctionLiteral::ArityRestriction arity_restriction,
bool* ok) {
return parser_->ParseFunctionLiteral(name, function_name_location,
name_is_strict_reserved, is_generator,
- function_token_position, type, ok);
+ function_token_position, type,
+ arity_restriction, ok);
}
@@ -1016,6 +1018,7 @@ FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) {
shared_info->is_generator(),
RelocInfo::kNoPosition,
function_type,
+ FunctionLiteral::NORMAL_ARITY,
&ok);
// Make sure the results agree.
ASSERT(ok == (result != NULL));
@@ -1865,6 +1868,7 @@ Statement* Parser::ParseFunctionDeclaration(ZoneStringList* names, bool* ok) {
is_generator,
pos,
FunctionLiteral::DECLARATION,
+ FunctionLiteral::NORMAL_ARITY,
CHECK_OK);
// Even if we're not at the top-level of the global or a function
// scope, we treat it as such and introduce the function with its
@@ -3275,9 +3279,16 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
bool is_generator,
int function_token_pos,
FunctionLiteral::FunctionType function_type,
+ FunctionLiteral::ArityRestriction arity_restriction,
bool* ok) {
// Function ::
// '(' FormalParameterList? ')' '{' FunctionBody '}'
+ //
+ // Getter ::
+ // '(' ')' '{' FunctionBody '}'
+ //
+ // Setter ::
+ // '(' PropertySetParameterList ')' '{' FunctionBody '}'
int pos = function_token_pos == RelocInfo::kNoPosition
? peek_position() : function_token_pos;
@@ -3370,7 +3381,9 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
Scanner::Location dupe_error_loc = Scanner::Location::invalid();
Scanner::Location reserved_loc = Scanner::Location::invalid();
- bool done = (peek() == Token::RPAREN);
+ bool done = arity_restriction == FunctionLiteral::GETTER_ARITY ||
+ (peek() == Token::RPAREN &&
+ arity_restriction != FunctionLiteral::SETTER_ARITY);
while (!done) {
bool is_strict_reserved = false;
Handle<String> param_name =
@@ -3395,6 +3408,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
*ok = false;
return NULL;
}
+ if (arity_restriction == FunctionLiteral::SETTER_ARITY) break;
done = (peek() == Token::RPAREN);
if (!done) Expect(Token::COMMA, CHECK_OK);
}
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698