Index: src/ast/scopes.cc |
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
index c7ef42e1b2295442b5be9f26b9a1b5859ca0c532..77c5d628f7ec86ca5de28a318b754d2d80f1d790 100644 |
--- a/src/ast/scopes.cc |
+++ b/src/ast/scopes.cc |
@@ -560,6 +560,11 @@ Variable* Scope::NewTemporary(const AstRawString* name) { |
int Scope::RemoveTemporary(Variable* var) { |
DCHECK_NOT_NULL(var); |
+ // Temporaries are only placed in ClosureScopes. |
+ DCHECK_EQ(ClosureScope(), this); |
+ DCHECK_EQ(var->scope()->ClosureScope(), var->scope()); |
+ // If the temporary is not here, return quickly. |
+ if (var->scope() != this) return -1; |
// Most likely (always?) any temporary variable we want to remove |
// was just added before, so we search backwards. |
for (int i = temps_.length(); i-- > 0;) { |