Repository navigation
Closed
Description
Problem
VECTOR ELM MAP with cross-dimension sources (e.g., c[DimA] = VECTOR ELM MAP(b[B1], a[DimA]) where b[B1] is from DimB used in a DimA context) fails to compile with dimension mismatch errors. The compiler cannot resolve the dimension relationship between DimB (source dimension) and DimA (target dimension).
Why it matters
- Blocking: Prevents enabling the full
vector.mdltest model in the integration tests (currently onlyvector_simple.mdlsubset works, which excludes cross-dimension indexing) - Design gap: Highlights a limitation in the compiler's cross-dimension indexing strategy for array operations
- Correctness: Models using VECTOR ELM MAP with cross-dimension references are common in real SD models
Components affected
src/simlin-engine/src/compiler/(dimension resolution, array subscript handling)src/simlin-engine/src/compiler/dimensions.rs(dimension matching/inference)src/simlin-engine/src/compiler/subscript.rs(array subscript expansion)
Possible approaches
- Element-level subscript flattening: Flatten
b[B1]to a scalar before passing to VECTOR ELM MAP, allowing dimension mismatch resolution - Cross-dimension indexing mapping: Track dimension relationships through mappings (like EXCEPT does) to allow element selection across dimension boundaries
- Source dimension narrowing: When a source array has a subscript that narrows it to a single element (e.g.,
b[B1]), treat it as dimension-agnostic for the purposes of VECTOR ELM MAP
Context
Identified during design work for issue #355 (vector operations/ALLOCATE AVAILABLE VM implementation). The specific limitation is documented in a comment in src/simlin-engine/tests/simulate.rs around line 863:
// VECTOR ELM MAP with cross-dimension source: `VECTOR ELM MAP(b[B1], a[DimA])`
// uses b[B1] (a single-element B-subscript slice) as the source array in a DimA
// context. The compiler cannot resolve the dimension mismatch because b's DimB
// dimension has no mapping to DimA. Fixing requires either element-level subscript
// flattening or a new cross-dimension indexing strategy.
// The vector_simple subset (no cross-dim indexing) passes via simulates_vector_simple_mdl.
This is a distinct sub-case of cross-dimension dimension resolution (related to #345 EXCEPT+cross-dimension mapping) but specific to vector operations.
Metadata
Metadata
Assignees
Labels
No labels
Activity