Index: src/scopes.cc |
diff --git a/src/scopes.cc b/src/scopes.cc |
index 80c7eb2ae93bd8f49d8d885f4976c11c4229c620..7f663fd18e50736e41b5fd8c531d8dac434a89e8 100644 |
--- a/src/scopes.cc |
+++ b/src/scopes.cc |
@@ -1091,7 +1091,7 @@ bool Scope::MustAllocateInContext(Variable* var) { |
// Exceptions: temporary variables are never allocated in a context; |
// catch-bound variables are always allocated in a context. |
if (var->mode() == TEMPORARY) return false; |
- if (is_catch_scope() || is_block_scope()) return true; |
+ if (is_catch_scope() || is_block_scope() || is_module_scope()) return true; |
return var->has_forced_context_allocation() || |
scope_calls_eval_ || |
inner_scope_calls_eval_ || |
@@ -1235,7 +1235,8 @@ void Scope::AllocateVariablesRecursively() { |
// Force allocation of a context for this scope if necessary. For a 'with' |
// scope and for a function scope that makes an 'eval' call we need a context, |
// even if no local variables were statically allocated in the scope. |
- bool must_have_context = is_with_scope() || |
+ // Likewise for modules. |
+ bool must_have_context = is_with_scope() || is_module_scope() || |
(is_function_scope() && calls_eval()); |
// If we didn't allocate any locals in the local context, then we only |