mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-02 08:35:07 +08:00
- An evolving-any array (const fns = []; fns.push(() => 1)) lowers array<jsval> at its any[] declaration, but tsc's evolving-array analysis answers the pushed element type at later method calls, so the lowering handed monomorphized helpers a jsval-element receiver under a typed signature — the SC9001 validator ICE. - lowerArrayMethodCall now adopts the receiver VALUE's element type when it is a jsval-element array, riding the explicit-any[] handle-element lowering; HOF callback lead params bind the handles via jsvalParamOverrides whatever the evolved contextual type spelled. - Derived bindings keep the handle-element array instead of the evolved spelling: locals adopt the initializer's type in lowerVarDecl, and file-scope globals register the handle-element array for aliases and receiver-type-preserving chains (filter/slice/splice/concat) rooted at a registered one. - concat over a handle-element receiver decides spread-vs-element by the argument VALUE's array-ness, exactly JS's IsArray, instead of the evolved checker spelling. - Corpus fixtures 2510-2513 pin map, filter/forEach/some/every/findIndex, mixed push sites, and the slice/concat and function-scope derived shapes, byte-identical vs Node under --dynamic on both backends.
12 lines
542 B
TypeScript
12 lines
542 B
TypeScript
// @dynamic
|
|
// An evolving-`any` array of pushed closures flowing into a monomorphized
|
|
// .map: the binding lowered array<jsval> at its `any[]` declaration, while
|
|
// tsc's evolving-array analysis types the receiver by the pushed element
|
|
// at the call — the lowering monomorphizes on the VALUE's handle element
|
|
// (never a typed intrinsic over jsval elements), the callback binds the
|
|
// handle, and the number result exits to the static f64 array.
|
|
const fns = [];
|
|
fns.push(() => 1);
|
|
const result = fns.map(fn => fn());
|
|
console.log(result);
|