Fix optimizer slot clash during inlining and correct closure reduction

order

   - Add new_for_inlining to SubstitutionMap to preserve the next_slot
     counter, preventing local slot collisions when merging
     scopes.
   - Update Inliner to request fresh slots for parameters during beta
     reduction instead of forcing identity mappings.
   - Fix execution order in Optimizer::visit_node for closure inlining
     to run prepare_beta_reduction before visiting the function
     body, preventing corrupted upvalue captures.
   - Fix CLI --no-opt flag to correctly disable the optimizer in the ast
     binary.
   - Add integration test to prevent future slot clash regressions.
This commit is contained in:
Michael Schimmel
2026-03-06 11:58:28 +01:00
parent 3ded62d836
commit 1342c7ca8e
3 changed files with 12 additions and 13 deletions
@@ -38,6 +38,12 @@ impl SubstitutionMap {
inner
}
pub fn new_for_inlining(&self) -> Self {
let mut inner = self.new_inner();
inner.next_slot = self.next_slot;
inner
}
pub fn add_ast_substitution(&mut self, addr: Address, node: AnalyzedNode) {
self.ast_substitutions.insert(addr, Rc::new(node));
}