Repository navigation
Description
Problem
In src/simlin-engine/src/db.rs, the compile_implicit_var_fragment function (around lines 4041-4092) only resolves dependency names that exactly match entries in source_vars or implicit_info. Composite deps like module·output (using the middle-dot separator U+00B7) are silently dropped because they don't match either lookup.
In contrast, compile_var_fragment (lines 3344-3418) has explicit handling for composite module-output deps:
- Strips the leading
·prefix (parent model reference in XMILE) - Recognizes deps containing
·as module references - Looks up the module source variable
- Builds a
Variable::Modulewith resolved inputs - Adds
extra_module_refsandextra_submodelsentries for proper metadata resolution
The implicit var function skips all of this -- any dep name containing · falls through both source_vars.get() and implicit_info.contains_key() without matching, and is silently ignored.
Impact
If an implicit variable generated by SMOOTH/DELAY/TREND builtin expansion depends on a module output (e.g., SMTH1(some_module.output, delay_time)), the required module metadata will be missing from the mini-Module context used for compilation. This could cause:
- Offset resolution failures during bytecode compilation
- Incorrect compilation producing wrong simulation results
- Silent data corruption where the dep resolves to the wrong offset
This is a correctness bug in the monolithic compilation path, not an incremental pipeline gap. It affects the existing, production compilation pipeline.
Current State
No existing test models exercise this path -- all SMOOTH/DELAY test models use plain scalar deps. This is a valid pattern in real-world SD models that needs to work correctly.
Affected Component
src/simlin-engine/src/db.rs, functioncompile_implicit_var_fragment
Suggested Fix
Add composite dep handling to compile_implicit_var_fragment matching the pattern in compile_var_fragment (lines 3344-3418):
- Strip leading
·prefix from dep names - Check for
·in the effective name to identify module references - Look up the referenced module variable in
source_vars - Build a
Variable::Modulestub with resolved inputs - Add
extra_module_refsandextra_submodelsentries - Add a test model with
SMOOTH(module.output, dt)to cover this path
Related
- Issue engine: models with modules or SMOOTH/DELAY skip incremental compile #295 tracks incremental compilation gaps (where the incremental path falls back to monolithic). This issue is different: it is a correctness gap in the monolithic path itself.
Context
Identified during code review of the incremental compilation path (incremental-compilation-followup branch).
Activity