mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-02 05:31:11 +00:00
Fix #272
This commit is contained in:
parent
f21715c8c1
commit
4a0143302f
3 changed files with 15 additions and 0 deletions
|
@ -127,6 +127,14 @@ impl<K, V> Dict<K, V> {
|
||||||
pub fn clear(&mut self) {
|
pub fn clear(&mut self) {
|
||||||
self.dict.clear();
|
self.dict.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// remove all elements for which the predicate returns false
|
||||||
|
pub fn retain<F>(&mut self, f: F)
|
||||||
|
where
|
||||||
|
F: FnMut(&K, &mut V) -> bool,
|
||||||
|
{
|
||||||
|
self.dict.retain(f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K, V> IntoIterator for Dict<K, V> {
|
impl<K, V> IntoIterator for Dict<K, V> {
|
||||||
|
|
|
@ -950,6 +950,12 @@ impl Context {
|
||||||
self.kind = kind;
|
self.kind = kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn clear_invalid_vars(&mut self) {
|
||||||
|
self.locals.retain(|_, v| v.t != Failure);
|
||||||
|
self.decls.retain(|_, v| v.t != Failure);
|
||||||
|
self.params.retain(|(_, v)| v.t != Failure);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn pop(&mut self) -> Context {
|
pub fn pop(&mut self) -> Context {
|
||||||
if let Some(parent) = self.outer.as_mut() {
|
if let Some(parent) = self.outer.as_mut() {
|
||||||
let parent = mem::take(parent);
|
let parent = mem::take(parent);
|
||||||
|
|
|
@ -1978,6 +1978,7 @@ impl ASTLowerer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self.ctx.clear_invalid_vars();
|
||||||
self.ctx.check_decls().unwrap_or_else(|mut errs| {
|
self.ctx.check_decls().unwrap_or_else(|mut errs| {
|
||||||
self.errs.append(&mut errs);
|
self.errs.append(&mut errs);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue