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 |