mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-12 02:13:04 +08:00
An unannotated `const xs = []` inside a function takes the element type
its reads agree on, and is checked-dynamic when they disagree. An alias
taken between two writes of different element types (`const alias = xs`
after `xs.push(1)`, before `xs.push("two")`) took the element type the
checker gives it at that point, so it held a copy and missed the later
writes: Node prints `1,two 2` for `xs.join(","), alias.length`, the
compiled program printed `1,two 1`. An unannotated alias of such a binding,
and an alias of that alias, now takes the binding's checked-dynamic type,
so every name holds the one array.
A write that stores a value the agreed element type does not hold
(`xs.push("t")` after reads typed `boolean[]`, or `xs[1] = "one"`) now
makes the binding checked-dynamic too. Those programs were refused with
SC1090 "'string' values where 'boolean' is expected".
Fixes #1641.