Add example and refine local inlining

Add a new example file `examples/def_local_inlining.myc` to demonstrate
and test local inlining.

Refine the optimizer to handle local inlining more robustly by:
- Passing a `SubstitutionMap` to `visit_node` to track local variable
  substitutions.
- Enabling constant propagation for local variables by checking
  `sub.locals` in `BoundKind::Get`.
- Updating `BoundKind::DefLocal` and `BoundKind::Set` to maintain the
  substitution map for local variables.
- Adjusting `try_beta_reduce` to use the optimizer's `visit_node` with
  the substitution map for inlining.
- Re-indexing upvalues correctly when inlining captured variables into
  lambdas.
This commit is contained in:
Michael Schimmel
2026-02-21 22:35:04 +01:00
parent ff1024ee49
commit b2e010e755
4 changed files with 169 additions and 164 deletions
+4 -1
View File
@@ -52,7 +52,10 @@ pub fn run_functional_tests_with_level(level: u32) -> Vec<TestResult> {
results.push(TestResult {
name,
success: false,
message: format!("Level {}: Expected {}, got {}", level, expected, val_str),
message: format!(
"Level {}: Expected {}, got {}",
level, expected, val_str
),
});
}
}