1
0
Fork 0
mirror of synced 2025-09-23 04:08:33 +00:00

implement fold_program to avoid calling fold_module more than expected

This commit is contained in:
schaeff 2021-07-25 18:31:22 +02:00
parent a1cf614f53
commit a98701309d
2 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1 @@
Fix state corruption in the constant inliner

View file

@ -67,6 +67,17 @@ impl<'ast, 'a, T: Field> ConstantInliner<'ast, T> {
}
impl<'ast, T: Field> Folder<'ast, T> for ConstantInliner<'ast, T> {
fn fold_program(&mut self, p: TypedProgram<'ast, T>) -> TypedProgram<'ast, T> {
for (id, _) in p.modules {
self.fold_module_id(id);
}
TypedProgram {
modules: std::mem::take(&mut self.modules),
..p
}
}
fn fold_module_id(&mut self, id: OwnedTypedModuleId) -> OwnedTypedModuleId {
// anytime we encounter a module id, visit the corresponding module if it hasn't been done yet
if !self.treated(&id) {