You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
engine: SUM(VECTOR ELM MAP(...)) in A2A context evaluates per-element rather than reducing the full array #366
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 result gets 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
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)
Fixed in commit bb3e977 (PR #368) — A2A hoisting now correctly distinguishes array-value and scalar-element arguments for reducer-wrapped array-producing builtins.
Activity
engine: hoist nested vector builtins for scalar reducers (#369)
bpowers commentedon Mar 8, 2026
Fixed in commit bb3e977 (PR #368) — A2A hoisting now correctly distinguishes array-value and scalar-element arguments for reducer-wrapped array-producing builtins.