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

Unified Diff: src/parsing/parser.cc

Issue 1621663003: Version 4.9.385.11 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.9
Patch Set: 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 | « include/v8-version.h ('k') | 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 1002dd2237632b2e4bf7b48dc7d2bc29351220c6..b1b8c1316bce1c0c83dc07cc94e2621610145150 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -1895,6 +1895,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();
@@ -1921,7 +1922,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()) {
@@ -1932,8 +1933,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 | « include/v8-version.h ('k') | test/mjsunit/regress/regress-4693.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698