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
Unroll foreach over small constant arrays to make keys non-optional
When iterating over a constant array like ['b', 'c'] with a foreach loop,
all elements are guaranteed to be iterated. The fixed-point loop analysis
processes the body with the union type ('b'|'c'), which results in optional
keys since only one value is set per iteration.
This adds a post-loop unrolling refinement step that processes the body once
per element with specific types. This correctly determines that all keys are
definitely set after the loop completes, changing the result from
array{a: string, b?: int, c?: int} to array{a: string, b: int, c: int}.
The unrolling is limited to constant arrays with <= 8 elements, no optional
keys, no break statements, and no by-reference iteration.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0 commit comments