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

Unified Diff: src/parsing/parser.cc

Issue 1622723003: Sloppy mode webcompat: allow conflicting function declarations in blocks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add Annex B checks to test Created 4 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/mjsunit/regress/regress-4693.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 43443a96772aa8d4ce03ae1e50a9bf28b3508365..dd9744e7f6314d72f1b3b91ad4b28218da7d1225 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -1926,6 +1926,7 @@ Variable* Parser::Declare(Declaration* declaration,
DCHECK(proxy->raw_name() != NULL);
const AstRawString* name = proxy->raw_name();
VariableMode mode = declaration->mode();
+ bool is_function_declaration = declaration->IsFunctionDeclaration();
if (scope == nullptr) scope = scope_;
Scope* declaration_scope =
IsLexicalVariableMode(mode) ? scope : scope->DeclarationScope();
@@ -1952,7 +1953,7 @@ Variable* Parser::Declare(Declaration* declaration,
// Declare the name.
Variable::Kind kind = Variable::NORMAL;
int declaration_group_start = -1;
- if (declaration->IsFunctionDeclaration()) {
+ if (is_function_declaration) {
kind = Variable::FUNCTION;
} else if (declaration->IsVariableDeclaration() &&
declaration->AsVariableDeclaration()->is_class_declaration()) {
@@ -1963,8 +1964,11 @@ Variable* Parser::Declare(Declaration* declaration,
var = declaration_scope->DeclareLocal(
name, mode, declaration->initialization(), kind, kNotAssigned,
declaration_group_start);
- } else if (IsLexicalVariableMode(mode) ||
- IsLexicalVariableMode(var->mode()) ||
+ } else if (((IsLexicalVariableMode(mode) ||
+ IsLexicalVariableMode(var->mode())) &&
+ // Allow duplicate function decls for web compat, see bug 4693.
+ (is_strict(language_mode()) || !is_function_declaration ||
+ !var->is_function())) ||
((mode == CONST_LEGACY || var->mode() == CONST_LEGACY) &&
!declaration_scope->is_script_scope())) {
// The name was declared in this scope before; check for conflicting
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-4693.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698