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

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: Cleanup based on code review 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') | 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 3c72dd0f72c7b47b05c08da86de112bee65468eb..d0e1367bdd7b6ad8607343ac80d5c4028c56b2de 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;
@@ -3831,19 +3831,16 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
handler_count = function_state.handler_count();
}
- // Validate strict mode.
- // 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);
- }
+ // Validate name and parameter names. We can do this only after parsing the
+ // function, since the function can declare itself strict.
+ CheckFunctionName(language_mode(), kind, function_name,
+ name_is_strict_reserved, function_name_location,
+ CHECK_OK);
+ const bool use_strict_params = is_rest || IsConciseMethod(kind);
+ CheckFunctionParameterNames(language_mode(), use_strict_params,
+ eval_args_error_loc, dupe_error_loc,
+ reserved_error_loc, CHECK_OK);
+
if (is_strict(language_mode())) {
CheckStrictOctalLiteral(scope->start_position(), scope->end_position(),
CHECK_OK);
« no previous file with comments | « no previous file | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698