mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-10 01:56:15 +08:00
`t[i]` on a fixed-shape tuple where `i` is not a literal refused with SC1090. A tuple is a positional record, so the read now dispatches over its arity: the element at an integer index in [0, arity), and undefined for anything else — a fraction, a negative, NaN, Infinity, or one past the end, exactly Node's array-like read. The answer type is the join of the element types plus undefined, the same policy the array index read uses, so a consumer observes a miss like any other optional element read: `t[i]!` narrows through the existing checked-narrow path and arithmetic on a miss is NaN. The receiver and the index are hoisted into hidden locals when they cannot be repeated (receiver first, since JavaScript evaluates it before the key). The chain stays inline because the arity is a compile-time constant, unlike the lifted array helper whose length is not. Writes keep their fence: a stored position must be a literal index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>