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

Unified Diff: src/parsing/parser.cc

Issue 2274133002: Add function-var to variables_ so LookupRecursive doesn't need to special-case it (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: merge Created 4 years, 3 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 | « src/ast/scopes.cc ('k') | test/mjsunit/function-var.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 25dd736700f7c60c702554c46f27380447e443aa..d8e6761273e851d76067e8cb52d91986a8686ea6 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -3662,17 +3662,22 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
}
if (function_type == FunctionLiteral::kNamedExpression) {
- // Now that we know the language mode, we can create the const assignment
- // in the previously reserved spot.
- DCHECK_EQ(function_scope, scope());
- Variable* fvar = function_scope->DeclareFunctionVar(function_name);
- VariableProxy* fproxy = factory()->NewVariableProxy(fvar);
- result->Set(kFunctionNameAssignmentIndex,
- factory()->NewExpressionStatement(
- factory()->NewAssignment(Token::INIT, fproxy,
- factory()->NewThisFunction(pos),
- kNoSourcePosition),
- kNoSourcePosition));
+ Statement* statement;
+ if (function_scope->LookupLocal(function_name) == nullptr) {
+ // Now that we know the language mode, we can create the const assignment
+ // in the previously reserved spot.
+ DCHECK_EQ(function_scope, scope());
+ Variable* fvar = function_scope->DeclareFunctionVar(function_name);
+ VariableProxy* fproxy = factory()->NewVariableProxy(fvar);
+ statement = factory()->NewExpressionStatement(
+ factory()->NewAssignment(Token::INIT, fproxy,
+ factory()->NewThisFunction(pos),
+ kNoSourcePosition),
+ kNoSourcePosition);
+ } else {
+ statement = factory()->NewEmptyStatement(kNoSourcePosition);
+ }
+ result->Set(kFunctionNameAssignmentIndex, statement);
}
MarkCollectedTailCallExpressions();
« no previous file with comments | « src/ast/scopes.cc ('k') | test/mjsunit/function-var.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698