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

Unified Diff: src/parser.cc

Issue 899363002: Allow eval and arguments as property names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: expand test Created 5 years, 10 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 | src/preparser.h » ('j') | src/preparser.cc » ('J')
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 3c72dd0f72c7b47b05c08da86de112bee65468eb..94db25f8d4103cb8f027a7a3bf65c748bca08d66 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -3697,9 +3697,9 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
// We don't yet know if the function will be strict, so we cannot yet
// produce errors for parameter names or duplicates. However, we remember
// the locations of these errors if they occur and produce the errors later.
- Scanner::Location eval_args_error_log = Scanner::Location::invalid();
+ Scanner::Location eval_args_error_loc = Scanner::Location::invalid();
Scanner::Location dupe_error_loc = Scanner::Location::invalid();
- Scanner::Location reserved_loc = Scanner::Location::invalid();
+ Scanner::Location reserved_error_loc = Scanner::Location::invalid();
bool is_rest = false;
bool done = arity_restriction == FunctionLiteral::GETTER_ARITY ||
@@ -3716,11 +3716,11 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK);
// Store locations for possible future error reports.
- if (!eval_args_error_log.IsValid() && IsEvalOrArguments(param_name)) {
- eval_args_error_log = scanner()->location();
+ if (!eval_args_error_loc.IsValid() && IsEvalOrArguments(param_name)) {
+ eval_args_error_loc = scanner()->location();
}
- if (!reserved_loc.IsValid() && is_strict_reserved) {
- reserved_loc = scanner()->location();
+ if (!reserved_error_loc.IsValid() && is_strict_reserved) {
+ reserved_error_loc = scanner()->location();
}
if (!dupe_error_loc.IsValid() && scope_->IsDeclared(param_name)) {
duplicate_parameters = FunctionLiteral::kHasDuplicateParameters;
@@ -3835,14 +3835,19 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
// Concise methods use StrictFormalParameters.
// Functions for which IsSimpleParameterList() returns false use
// StrictFormalParameters.
- if (is_strict(language_mode()) || IsConciseMethod(kind) || is_rest) {
- CheckStrictFunctionNameAndParameters(function_name,
- name_is_strict_reserved,
- function_name_location,
- eval_args_error_log,
- dupe_error_loc,
- reserved_loc,
- CHECK_OK);
+ bool check_params =
+ is_strict(language_mode()) || IsConciseMethod(kind) || is_rest;
+ if (check_params) {
+ bool check_name = is_strict(language_mode()) && !IsConciseMethod(kind) &&
+ !IsAccessorFunction(kind);
+ if (!check_name) {
+ CheckStrictFunctionParameters(eval_args_error_loc, dupe_error_loc,
+ reserved_error_loc, CHECK_OK);
+ } else {
+ CheckStrictFunctionNameAndParameters(
+ function_name, name_is_strict_reserved, function_name_location,
+ eval_args_error_loc, dupe_error_loc, reserved_error_loc, CHECK_OK);
+ }
}
if (is_strict(language_mode())) {
CheckStrictOctalLiteral(scope->start_position(), scope->end_position(),
« no previous file with comments | « no previous file | src/preparser.h » ('j') | src/preparser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698