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

Unified Diff: src/parsing/parameter-initializer-rewriter.cc

Issue 2077283004: Rewrite scopes of non-simple default arguments (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix whitespace Created 4 years, 6 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 | src/parsing/parser.cc » ('j') | src/parsing/pattern-rewriter.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parameter-initializer-rewriter.cc
diff --git a/src/parsing/parameter-initializer-rewriter.cc b/src/parsing/parameter-initializer-rewriter.cc
index cbbf8deec7997c0f1bc5665c394c848ac3676baa..6362c63f8ec65863e97ffac96f362a1e6ced4c9d 100644
--- a/src/parsing/parameter-initializer-rewriter.cc
+++ b/src/parsing/parameter-initializer-rewriter.cc
@@ -90,6 +90,10 @@ void Rewriter::VisitVariableProxy(VariableProxy* proxy) {
if (proxy->is_resolved()) {
Variable* var = proxy->var();
if (var->mode() != TEMPORARY) return;
+ // For rewriting inside the same ClosureScope (e.g., putting default
+ // parameter values in their own inner scope in certain cases), refrain
+ // from invalidly moving temporaries to a block scope.
+ if (var->scope()->ClosureScope() == new_scope_->ClosureScope()) return;
int index = old_scope_->RemoveTemporary(var);
if (index >= 0) {
temps_.push_back(std::make_pair(var, index));
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | src/parsing/pattern-rewriter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698