Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index 2637281f080ed9f7f32fba93701c4da068a4f34e..89d73f52b6d6789aa0fc177281dac06b724c66b7 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -3296,10 +3296,25 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name, |
| // '(' (Identifier)*[','] ')' |
| Expect(Token::LPAREN, CHECK_OK); |
| int start_pos = scanner().location().beg_pos; |
| + Scanner::Location name_loc(RelocInfo::kNoPosition, RelocInfo::kNoPosition); |
|
Kevin Millikin (Chromium)
2011/01/21 11:41:56
This might be more readable with a factory functio
Martin Maly
2011/01/21 23:08:39
Done.
|
| + Scanner::Location dupe_loc(RelocInfo::kNoPosition, RelocInfo::kNoPosition); |
| bool done = (peek() == Token::RPAREN); |
| while (!done) { |
| Handle<String> param_name = ParseIdentifier(CHECK_OK); |
| + |
| + // Store locations for possible future error reports. |
| + if (name_loc.beg_pos == RelocInfo::kNoPosition && |
|
Kevin Millikin (Chromium)
2011/01/21 11:41:56
Likewise, struct Scanner::Location could have a pr
Martin Maly
2011/01/21 23:08:39
Done. The Location::IsValid felt best so I went wi
|
| + IsEvalOrArguments(param_name)) { |
| + // Store location for later |
|
Kevin Millikin (Chromium)
2011/01/21 11:41:56
This comment is probably redundant and so's the on
Martin Maly
2011/01/21 23:08:39
Done.
|
| + name_loc = scanner().location(); |
| + } |
| + if (dupe_loc.beg_pos == RelocInfo::kNoPosition && |
| + top_scope_->IsDeclared(param_name)) { |
|
Kevin Millikin (Chromium)
2011/01/21 11:41:56
Indentation is off here.
Martin Maly
2011/01/21 23:08:39
Done.
|
| + // Store location for later |
| + dupe_loc = scanner().location(); |
| + } |
| + |
| Variable* parameter = top_scope_->DeclareLocal(param_name, Variable::VAR); |
| top_scope_->AddParameter(parameter); |
| num_parameters++; |
| @@ -3384,6 +3399,18 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name, |
| *ok = false; |
| return NULL; |
| } |
| + if (name_loc.beg_pos != RelocInfo::kNoPosition) { |
| + ReportMessageAt(name_loc, "strict_param_name", |
| + Vector<const char*>::empty()); |
| + *ok = false; |
| + return NULL; |
| + } |
| + if (dupe_loc.beg_pos != RelocInfo::kNoPosition) { |
| + ReportMessageAt(dupe_loc, "strict_param_dupe", |
| + Vector<const char*>::empty()); |
| + *ok = false; |
| + return NULL; |
| + } |
| // TODO(mmaly): Check for octal escape sequence here. |
| } |