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

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: Update comments 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') | no next file » | 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 e3ddc907e49f3385839484660a0332739f91d8f0..31313fd513a796d60bbc15fe39b1ba30831998d1 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -3657,17 +3657,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->Lookup(function_name) == nullptr) {
adamk 2016/09/19 18:00:39 Do you mean LookupLocal? Please add a test that wo
+ // 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(0);
adamk 2016/09/19 18:00:39 Why 0 instead of kNoSourcePosition?
+ }
+ result->Set(kFunctionNameAssignmentIndex, statement);
}
MarkCollectedTailCallExpressions();
« no previous file with comments | « src/ast/scopes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698