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

Unified Diff: src/parsing/parser.cc

Issue 1851673007: [modules] Treat top-level functions as lexical (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Re-implement logic in ParseFunctionDeclaration Created 4 years, 8 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/cctest/test-parsing.cc » ('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 8310ad948c543de2cfa10689062e10e1a1106496..fa4d7231d4e020b1d561475061f542e5ec2a5a6e 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -2092,7 +2092,9 @@ Statement* Parser::ParseFunctionDeclaration(
// initial value upon entering the corresponding scope.
// In ES6, a function behaves as a lexical binding, except in
// a script scope, or the initial scope of eval or another function.
- VariableMode mode = !scope_->is_declaration_scope() ? LET : VAR;
+ VariableMode mode =
+ (!scope_->is_declaration_scope() || scope_->is_module_scope()) ? LET
+ : VAR;
VariableProxy* proxy = NewUnresolved(name, mode);
Declaration* declaration =
factory()->NewFunctionDeclaration(proxy, mode, fun, scope_, pos);
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698