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

Unified Diff: src/ast/scopes.cc

Issue 2520883002: [parser] Fix scopes in rewriting of for-of and destructuring assignments. (Closed)
Patch Set: Take into account that the scope may have been removed when we get to rewrite. Created 4 years, 1 month 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
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index c150336668545eb1a8bf78b3af3823f70bb476c1..21d67bcf5b24288f9f8dcb12f1200a5af67989c6 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -636,6 +636,22 @@ Variable* DeclarationScope::DeclareFunctionVar(const AstRawString* name) {
return function_;
}
+bool Scope::HasBeenRemoved() const {
+ Scope* parent = outer_scope();
Toon Verwaest 2016/11/22 08:30:18 if (is_declaration_scope()) return false; ?
Dan Ehrenberg 2016/11/22 16:07:00 Or, that could be an assertion before the return t
Toon Verwaest 2016/11/22 16:18:37 That's what I was originally thinking of suggestin
neis 2016/11/23 12:51:08 Done.
+ if (parent == nullptr) {
+ DCHECK(is_script_scope());
+ return false;
+ }
+
+ Scope* sibling = parent->inner_scope();
+ for (; sibling != nullptr; sibling = sibling->sibling()) {
+ if (sibling == this) return false;
+ }
Dan Ehrenberg 2016/11/22 16:07:00 This is asymptotically a bit unfortunate. Is there
Toon Verwaest 2016/11/22 16:19:47 Yeah that's a good suggestion though. We can just
+
+ DCHECK_NULL(inner_scope_);
+ return true;
+}
+
Scope* Scope::FinalizeBlockScope() {
DCHECK(is_block_scope());
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser.h » ('j') | src/parsing/pattern-rewriter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698