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

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: Created 4 years, 9 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 8128670128b5512505c3a1c21d017b57f9c059b9..5445887e18eba89b19c4eaa936bd06ae24a64c3c 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -1910,7 +1910,12 @@ Variable* Parser::Declare(Declaration* declaration,
var = declaration_scope->DeclareLocal(
name, mode, declaration->initialization(), kind, kNotAssigned);
} else if ((IsLexicalVariableMode(mode) ||
- IsLexicalVariableMode(var->mode())) &&
+ IsLexicalVariableMode(var->mode()) ||
+ // At the top level of a Module, function declarations are
+ // treated like lexical declarations rather than like var
+ // declarations.
+ (declaration_scope->is_module_scope() &&
adamk 2016/04/04 22:19:54 This code belongs not here, but in Parser::ParseFu
mike3 2016/04/13 21:18:44 Of course, that makes much more sense.
+ (is_function_declaration || var->is_function()))) &&
// Lexical bindings may appear for some parameters in sloppy
// mode even with --harmony-sloppy off.
(is_strict(language_mode()) || allow_harmony_sloppy())) {
« 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