Repository navigation
Description
Problem
compile_implicit_var_fragment in src/simlin-engine/src/db.rs (around lines 4120-4136) only collects graphical-function tables from the implicit variable itself via lowered.tables(), not from its dependency variables. In contrast, compile_var_fragment (lines 3558-3580) iterates over all dependency variables and collects their tables too.
The relevant code pattern in compile_var_fragment:
// compile_var_fragment collects tables from deps:
for dep_var in &dep_vars {
for (name, table) in dep_var.tables() {
tables.insert(name, table);
}
}While compile_implicit_var_fragment only does:
// Only collects tables from the implicit var itself:
for (name, table) in lowered.tables() {
tables.insert(name, table);
}Impact
If an implicit helper variable (from DELAY/SMOOTH/PREVIOUS/TREND builtin expansion) contains a LOOKUP reference to a dependency that has graphical functions (e.g., DELAY1(LOOKUP(table_var, x), ...)), the dependency's table data would be missing from the mini-module's tables map. The bytecode compiler would then fail when trying to emit LOOKUP opcodes because the table data is not available.
Current impact is minimal -- implicit variables from DELAY/SMOOTH/PREVIOUS/TREND expansion don't use LOOKUP functions, and their dependencies in current test models don't have graphical functions. All 32 integration test models pass today.
However, this is a latent correctness gap that could surface with more complex real-world models where builtin expansions reference variables with graphical functions.
Affected Component
src/simlin-engine/src/db.rs, functioncompile_implicit_var_fragment
Suggested Fix
Extend compile_implicit_var_fragment to iterate over dependency variables and collect their tables, matching the pattern used in compile_var_fragment. Add a test model that exercises this path (e.g., a model where a DELAY input references a graphical-function variable).
Related
- Issue compile_implicit_var_fragment drops composite module·output deps #301 tracks a different gap in the same function: composite module-output deps being silently dropped. This issue is specifically about graphical-function table data not being collected from dependencies.
Context
Identified during PR #300 code review (Codex reviewer, P2 severity).
Activity