-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Description
Problem
When an array-producing builtin like VECTOR ELM MAP is wrapped in a reducer like SUM() and the entire expression appears in an A2A (apply-to-all) context, the hoisting logic treats the inner array-producing builtin as the primary expression shape. This causes the outer SUM() to evaluate per-element rather than first materializing the full array and then reducing it.
For example, with result[DimA] = SUM(VECTOR ELM MAP(source[*], offsets[*])):
- Expected: each element of
resultgets the same scalar value (the sum of all mapped elements) - Actual: the A2A hoisting detects the inner VEM and hoists it, but the outer SUM is applied per-element rather than over the full materialized array
Relationship to other issues
- Overlaps with engine: array-producing builtins nested inside other BuiltinFn calls produce incorrect results in interpreter #364 (array-producing builtins nested inside other BuiltinFn calls in interpreter), but this issue is specifically about the A2A expansion path in the compiler
- Related to compiler/context: preserve_wildcards flag conflates reducer and vector builtin semantics for ActiveDimRef #365 (preserve_wildcards conflation), since the same flag controls both reducer and vector builtin dimension preservation
Context
Identified during code review of PR #361 (VM vector operations). Referenced in the PR summary as a deferred pre-existing issue but not previously filed. The issue predates the PR and affects both interpreter and VM paths.
Component(s) affected
src/simlin-engine/src/compiler/mod.rs(A2A hoisting detection and expansion)src/simlin-engine/src/compiler/context.rs(preserve_wildcards_for_iteration semantics)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels