mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-05 08:13:06 +08:00
Array reduce typed its accumulator by the call's checked type, widened with undefined only when the callback could return a missing value or a receiver without an initial value could have holes. Three runtime values fell outside it and threw "not representable in the target union": - an initial value read from a missing element; - a callback result of another primitive (`missing[0] ?? "fallback"`); - a callback wrapped in parentheses, which the analysis and the callback lowering did not see as the arrow it wraps. The accumulator now also takes undefined from a possibly missing initial value, and the primitive arms the callback's result can have. Array callbacks are taken without their parentheses. `arguments.length` in a fixed-arity function expression folded to its declared parameter count. When the expression flows into a fixed-arity function type with more parameters, as array callbacks do (value, index, array, and the accumulator for reduce), every call passes that type's count, and the length is that count.