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

Unified Diff: src/parsing/pattern-rewriter.cc

Issue 2634123002: [parser] Pessimistically assume top-level variables will be assigned. (Closed)
Patch Set: Feedback. Created 3 years, 11 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/pattern-rewriter.cc
diff --git a/src/parsing/pattern-rewriter.cc b/src/parsing/pattern-rewriter.cc
index edd283e9d62f7a484b4f16a7149b0ab4d7903ae2..9eb3f0665be3030344a7fc4522310b6159eb2e77 100644
--- a/src/parsing/pattern-rewriter.cc
+++ b/src/parsing/pattern-rewriter.cc
@@ -224,6 +224,14 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
} else {
DCHECK_NOT_NULL(proxy);
DCHECK_NOT_NULL(proxy->var());
+ if (var_init_scope->is_script_scope() ||
+ var_init_scope->is_module_scope()) {
+ // We have to pessimistically assume that top-level variables will be
+ // assigned. This is because there may be lazily parsed top-level
adamk 2017/01/17 18:09:04 As discussed offline, this comment is slightly mis
+ // functions, which, for efficiency, we preparse without variable
+ // tracking.
+ proxy->set_is_assigned();
+ }
}
// Add break location for destructured sub-pattern.
int pos = IsSubPattern() ? pattern->position() : value->position();
« 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