This commit is contained in:
Folkert 2022-04-30 21:22:47 +02:00
parent d3f00c8c6d
commit be6006bbab
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -363,12 +363,16 @@ impl Scope {
// - exposed_ident_count: unchanged // - exposed_ident_count: unchanged
// - home: unchanged // - home: unchanged
let aliases_count = self.aliases.len(); let aliases_count = self.aliases.len();
let locals_snapshot = self.locals.snapshot(); let locals_snapshot = self.locals.in_scope.len();
let result = f(self); let result = f(self);
self.aliases.truncate(aliases_count); self.aliases.truncate(aliases_count);
self.locals.revert(locals_snapshot);
// anything added in the inner scope is no longer in scope now
for i in locals_snapshot..self.locals.in_scope.len() {
self.locals.in_scope.set(i, false);
}
result result
} }
@ -459,18 +463,6 @@ impl ScopedIdentIds {
} }
} }
fn snapshot(&self) -> usize {
debug_assert_eq!(self.ident_ids.len(), self.in_scope.len());
self.ident_ids.len()
}
fn revert(&mut self, snapshot: usize) {
for i in snapshot..self.in_scope.len() {
self.in_scope.set(i, false);
}
}
fn has_in_scope(&self, ident: &Ident) -> Option<(Symbol, Region)> { fn has_in_scope(&self, ident: &Ident) -> Option<(Symbol, Region)> {
match self.contains_ident(ident.as_str()) { match self.contains_ident(ident.as_str()) {
ContainsIdent::InScope(symbol, region) => Some((symbol, region)), ContainsIdent::InScope(symbol, region) => Some((symbol, region)),