-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Problem
The Ast::Arrayed enum variant in src/simlin-engine/src/ast/mod.rs has no slot for a default expression. As a result, parse_equation in src/simlin-engine/src/variable.rs (around line 391) discards the default_equation field when converting from Equation::Arrayed to Ast::Arrayed.
This is currently safe because the MDL converter always expands all subscripted elements at conversion time, applying the default expression to non-EXCEPT elements before the compiler ever sees the equation. The compiler therefore never encounters a sparse Equation::Arrayed with missing elements that would need the default.
Why it matters
This is fragile. If any future code path produces an Equation::Arrayed with sparse elements and a non-trivial default equation, the compiler would silently default to 0.0 for missing elements instead of using the intended default expression. This could cause incorrect simulation results that are difficult to diagnose, since the failure mode is silent value substitution rather than an error.
Components affected
src/simlin-engine/src/ast/mod.rs--Ast::Arrayedenum variantsrc/simlin-engine/src/variable.rs--parse_equationfunction
Possible approach
Add an Option<Expr> field to Ast::Arrayed to carry the default expression through to the compiler. When the compiler encounters an arrayed variable with missing elements, it would use this default expression instead of falling back to 0.0.
Context
Identified during work on the mdl-full-compat branch while reviewing how arrayed equations flow through the parse/compile pipeline.