Fix inferred types memory leak (#1566)

This commit is contained in:
0HyperCube 2024-01-13 16:22:35 +00:00 committed by GitHub
parent bf0ec2c9c8
commit 1ac7b92b45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -648,9 +648,17 @@ impl TypingContext {
/// and store them in the `inferred` field. The proto network has to be topologically sorted
/// and contain fully resolved stable node ids.
pub fn update(&mut self, network: &ProtoNetwork) -> Result<(), GraphErrors> {
let mut deleted_nodes = self.inferred.keys().copied().collect::<HashSet<_>>();
for (id, node) in network.nodes.iter() {
self.infer(*id, node)?;
deleted_nodes.remove(id);
}
for node in deleted_nodes {
self.inferred.remove(&node);
}
Ok(())
}