feat: Add --no-opt flag and a failing test case
Introduce a --no-opt flag to disable compiler optimizations and add a new integration test case to reproduce a slot clash issue during inlining.
This commit is contained in:
+2
-2
@@ -42,8 +42,8 @@ struct Cli {
|
||||
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
let env = Environment::new();
|
||||
// Use env.optimization setting if needed, though it's currently on by default
|
||||
let mut env = Environment::new();
|
||||
env.optimization = !cli.no_opt;
|
||||
|
||||
// Load libraries
|
||||
for lib_path in &cli.lib {
|
||||
|
||||
@@ -756,4 +756,31 @@ mod tests {
|
||||
.any(|m| m.contains("Invalid arguments for function call"))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_optimizer_inlining_slot_clash_repro() {
|
||||
let mut env = Environment::new();
|
||||
env.optimization = true;
|
||||
|
||||
// This exactly mirrors err.myc structure.
|
||||
// NOTE: We must use a dynamic call like (series :float) here.
|
||||
// Simple constants like (def history 100) might be constant-folded or
|
||||
// inlined as values by the optimizer before the slot-clash can occur.
|
||||
// By using a series, we force the result into a local slot at runtime,
|
||||
// which triggers the conflict when the inliner fails to remap slots correctly.
|
||||
let source = r#"
|
||||
(do
|
||||
(def outer (fn [length]
|
||||
(do
|
||||
(def history (series :float))
|
||||
(fn [val] length)
|
||||
)
|
||||
))
|
||||
((outer 20) 5)
|
||||
)
|
||||
"#;
|
||||
|
||||
let res = env.run_script(source).unwrap();
|
||||
assert_eq!(format!("{}", res), "20");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user