Commit Graph
241 Commits
Author SHA1 Message Date
Chris Tate a0d2ce24f5 Record width composes with hybrid shapes, and per-field lifts cover unknown, upcasts, and clean function adapters
- recordWidthPlan narrows index-signature sources into declared-only targets (declared fields copy off their struct slots, the overflow drops with the width); absent-field completion declines there — the overflow could hold the key at runtime, and a completed undefined would drop the value Node keeps
- the overflow capture initializes same-named declared target fields directly off the source, admitting REQUIRED declared members; literal writes to names the target does not declare go overflowOnly, and a dispatch-writes gate keeps the validator's collision rule for the rest
- widthLiftPlan gains dynIn (a typed field into an 'unknown' slot — the static→DOM deep copy), upcast (derived into base, the prefix-layout reinterpret), and funcAdapt (funcCoerceAdapter's CLEAN subset — the stranded trap-only dispositions stay top-level, never inside a width plan)
- SC2002 now names the first blocking rule per record pair (describeRecordWidthBlocker mirrors the planners' gates) and its message/hint/registry entry speak the width-copy truth — the manifest flips the one entry name
- corpus 2556/2557 pin both hybrid directions and the new lifts byte-identical vs Node on both backends; diagnostics fixture record-width pins the residue's pointed messages
2026-07-23 20:36:50 -05:00
Chris Tate 176d963ea1 Index signatures carry function, Map, and Set values through the overflow store
- isSupportedIndexValue admits func/map/set: the overflow map's RC and trace machinery is already fully type-directed (scr_closure/scr_map adapters, the cycle fixpoint's map rule recursing on the value), and nested index-signature records rode the record kind all along
- the C keyed-read miss trap can now describe Map/Set-typed slots (dynDesc), reachable only through that message — no dynCheck ever expects a container
- SC2006's message and hint name the real value domain (functions, Maps, Sets, RegExps, Promises, ...) and the honest blockers left: symbol keys, dual signatures with unequal value types, and values with no representation at all
- diagnostics fixtures pivot to still-fenced shapes (Uint8Array values, unequal duals, a Date-valued bag); corpus 2558/2559 pin the command-registry and container-table patterns — declared+overflow hybrids, enumeration, delete, registry-capturing cycles, container churn — byte-identical vs Node on both backends
2026-07-23 20:36:21 -05:00
Chris Tate fa7cc089a9 The en-US Intl slice: composed NumberFormat and toLocaleString go static, the rest fences by name
- new Intl.NumberFormat("en-US").format(x), the callable spelling, and x.toLocaleString("en-US") lower to one runtime formatter with default options: decimal notation, 0-3 fraction digits rounded half-up on the SHORTEST round-tripping decimal (ICU's rounding input, probed against Node — format(1.0005) is "1.001" though toFixed(3) answers "1.000"; 1e23 prints the shortest form's zeros, not the exact expansion), "," grouping, "∞"/"NaN" texts, and "-0" for negatives rounding to zero. The en-US/latn symbols are the whole embedded locale surface — no ICU is linked.
- The Ryū digit core factors out of scr_f64_to_str as scr_f64_digits (same bytes; the 1M-double oracle gate stays green) and feeds the formatter; a 30,000-double ad-hoc fuzz across magnitude regimes matched Node byte-for-byte on both backends.
- Every unlowered Intl form fences by NAME with its own reason: the environment-default locale a compiled binary cannot carry (no-locale forms), other locales and the rest of the namespace (DurationFormat, DateTimeFormat, PluralRules, getCanonicalLocales — ICU data the binary does not embed; Node 24's DurationFormat additionally throws V8-internal Temporal errors with embedded source paths, so byte parity there is a version-dependent landmine), options bags, formatter values (the composed form is the lowered shape), and non-number format arguments.
- Differential fixture 2562 pins the rounding discriminators, grouping, ±0/NaN/∞, tiny and huge edges, and both spellings byte-identically vs Node on both backends; the new intl diagnostics fixture pins every named fence, and the Intl hints across the identifier/member/type chokepoints now teach what lowers.
2026-07-23 20:30:47 -05:00
Chris Tate 6162354076 esbuild's __toESM external-dependency interop compiles under --npm-static
- The bundler-CJS rewrite erases recognized __toESM(require("x")) wrappers — module-scope bindings, the `, 1` node-mode variant, inline member reads — down to the bare require at its original offsets; .default accesses pad to the binding where Node's answer is the module (plain-CJS targets, node mode) and stay member reads for __esModule-stamped targets, decided by a require-resolution probe over the target's shipped source (forwarding chains followed)
- Interop the recognizer cannot finish — deviant helper text, escaping interop objects, non-literal arguments, ESM-output calls — answers { degrade }: the fs shadow reports the package as an offender with a note naming the construct and the fallback loop islands it, never a failed build and never the silent alternative (a live helper chain's `var __create = Object.create;` fences at module load while the report claims static); auto and explicit opt-ins share the path
- Bare requires of opted-in packages now behave like relative ones end to end: requireInitStmt emits the dep's inline %init (previously the module never initialized before its exports were read), and cjsLocalModuleBindingOf/resolveValueSymbol resolve member reads and namespace method calls through the npm-static dep's export table
- Erased wrappers join the neutralize set so the helper sweep drops the whole dead chain, hoisted canonical-table texts copied off the source drop .default on module-valued bindings exactly like the pads do, and a file with interop pads but no canonical table still rewrites pads-only
- Fixtures gtcore/gtwrap/gtdrift with cases 2556-toesm-external (byte-matches Node across both dep shapes and the comma-call spelling) and 2557-toesm-drift (construct-naming degrade under explicit and auto opt-ins), excluded from the flagless island lane like the 246x family
2026-07-23 20:23:42 -05:00
Chris Tate b31d160fbd Object.is goes static with the spec's SameValue
- Number pairs take a new scr_num_same_value runtime primitive (NaN equals NaN, +0 differs from -0 — the two divergences from ===); strings, booleans, unit literals, and every reference kind (arrays, records, class instances with hierarchy widening, functions, class values, Maps/Sets, symbols, typed arrays, promises) ride exactly the strict-equality machinery, whose answers SameValue shares.
- Union operands lower through unionEq, which grows a sameValue flag: the f64 arm's payload compare upgrades to SameValue (a separate interned C helper per union; the LLVM lane calls the runtime primitive inline), every other arm is shared between the two semantics.
- Statically disjoint kind pairs answer the constant false with the operands still evaluated for their effects (Object.is is (any, any) — tsc admits every pair); dyn/jsval operands and partially-overlapping unions fence by name with strict equality's validate/narrow-first stance.
- Differential fixture 2561 pins the NaN/±0 edges, mixed-kind calls with effect counting, reference identity across kinds, and union payloads (including NaN/±0 inside a union and union-vs-plain wraps) byte-identically vs Node on both backends; stdlib-fence pins the named fences.
- Found pre-existing (reproduced at the base commit): the C backend SIGSEGVs on console.log(asBase === d, asBase === new Base()) — an upcast identity compare plus a constructing compare in one call; the fixture avoids the shape and the bug is reported for a follow-up lane.
2026-07-23 20:15:31 -05:00
Chris Tate f9cbff164f Library mode takes the static-or-refuse npm posture: eligible packages compile, SC4013 refuses the rest
- compileLibrary runs the --npm-static eligibility bar automatically over every bare specifier the graph exposes (opted-in packages' own import and top-level require edges included, iterated to a fixpoint) — an eligible package compiles statically into the library graph, and every fallback the shared frontend records refuses as SC4013 naming the package, the specific failed bar, and the vendor-or-drop remedy (with the profile's SC4013 teaching riding the hint), never SC1010/SC2013's executable-lane teachings.
- requireInitStmt now emits the guarded %init call for a bare require naming another opted-in package: the dep's module body never ran before (NULL-closure crash at first use), a latent npm-static gap on both lanes that the library fixpoint hits immediately; the executable lane never exercised an inter-package require.
- Contract facts exclude statically-compiled npm files (their .d.ts is dropped by construction, so no npm declaration can name a wire-contract type) while their bytes keep joining source_hash/build_id through moduleOrder; the sidecar stays byte-deterministic and a package-file edit flips both identity hashes.
- Builtins keep their story under the npm posture: async_free builtin imports compile alongside npm code, event-loop surfaces still refuse SC4005, no new fence.
- New fixtures npm-static, npm-refuse, and contract-npm vendor fake packages per the tests/fixtures/npm precedent; the K12 suites assert the compile and refusal sides on both emissions and the contract suite covers the identity-hash implications.
2026-07-23 20:06:31 -05:00
Chris Tate e1f93475cb Deliver runtime-detected library traps structured, with codes, entry symbols, and profile overlays
- The library trap funnel (scr_library.c) now assembles every detected trap into the ratified 0x01 text 0x1F code 0x1F symbol [0x1F remediation] form: the baseline human line rides unchanged as field 0, and 0x01-led messages (facade-authored throws, the compile-time SC4012 contract trap) still pass verbatim.
- Trap kinds classify over the runtime's own message conventions into a new SC4013-SC4019 runtime code family (escaped exception, range, type, syntax, OOM, internal invariant, residual), documented beside SC4012 in the diagnostics registry; no arithmetic kind exists because no runtime site can fire one.
- Every generated entry prologue (init, reset, collect, each export, both emissions) records its external symbol in a SCR_LIB-only static slot the funnel reads, so the structured message names the trapping entry as the host linked it; profile teachings/remediations for the family land as a program-TU overlay table both backends emit identically.
- K5/K7/init-trap fixtures now pin the structured layout with the spec's parse rule (default text, code, entry symbol, fields=3 on a no-teachings profile), and new K12 tests pin the SC4014 teaching/remediation overlay plus the undeclared-code default; the verbatim and text-leads-printable pins stay.
- The default executable lane is byte-identical (signature-stripped cmp over a stash/rebuild pair); all library suites and the diagnostics suite are green on both emissions.
2026-07-23 19:57:38 -05:00
Chris Tate 9a7e42fd1b Fresh-ArrayBuffer erasure, DataView setters, and named buffer fences
- new Uint8Array/Uint32Array/Int32Array/Float32Array(new ArrayBuffer(n)) erases the buffer into a zero-filled view exactly like the SharedArrayBuffer sleep idiom (literal byte length divisible by the element size), and new DataView(new ArrayBuffer(n), off?, len?) views a fresh zeroed allocation — nothing else can reference the buffer, so the erasure is exact.
- The DataView setter family (setUint8/Int8/Uint16/Int16/Uint32/Int32/Float32/Float64) lowers end to end: one scr_dataview_set runtime mirror of the getter (ToIndex offsets, Node's constant RangeError, modular integer truncation, double→float rounding, both endiannesses) wired through both backends; the bigint and Float16 setters keep the member fence.
- The resizable surface fences by NAME everywhere it can appear: new ArrayBuffer/resize/transfer/maxByteLength and SharedArrayBuffer.grow now state the reason (no free-standing ArrayBuffer value exists; grow has no threads to share with) at the constructor, identifier, member, and declared-type chokepoints, including the maxByteLength options bag inside an otherwise-erasable position.
- Differential fixture 2560 pins the erasure forms, every setter width/endianness/coercion, aliasing through x.buffer views, and the RangeError edges byte-identically vs Node on both backends; es2025-fences/dataview/stdlib-fence snapshots pin the new named hints.
2026-07-23 19:45:15 -05:00
Chris Tate 7b8e1452b3 The monomorphization frontier: keyof constraints, interface receivers, and signature bindings
- keyof-constrained generics specialize per literal key; keyed record writes take the literal-key type rule
- Generic methods called through interface-typed receivers monomorphize against the proven class
- Generic-signature annotations monomorphize their function initializers; generic-fn aliases register their target
- Fixtures 2550-2555 byte-identical on both backends

# Conflicts:
#	packages/compiler/src/diagnostics/diagnostic.ts
#	packages/compiler/src/frontend/lowering/lower-modules.ts
#	packages/compiler/src/frontend/lowering/lower-stmts.ts
#	packages/compiler/src/frontend/types.ts
#	packages/compiler/test/ts7/baselines/order-parity.json
#	tests/harness/__snapshots__/generic-methods.ts.txt
#	tests/harness/__snapshots__/generic-value-bindings.ts.txt
#	tests/harness/__snapshots__/mixins.ts.txt
#	tests/harness/__snapshots__/stdlib.ts.txt
2026-07-23 18:48:49 -05:00
Chris Tate 18f2cf2df0 Library traps carry the structured teaching encoding
- Trap messages assemble as 0x01 text 0x1F code 0x1F symbol with an optional remediation field, built once at export resolution so both backends emit identical bytes
- Thrown messages already leading with the marker pass to the sink verbatim through a length-delimited funnel entry
- Profiles refuse teaching and remediation strings containing the reserved bytes; embedder codes validate only as clean tokens
- A conformance fixture parses the structured bytes with the ten-line host rule and pins printable-first-byte on baseline messages

# Conflicts:
#	packages/compiler/src/diagnostics/diagnostic.ts
2026-07-23 18:01:24 -05:00
Chris Tate d6b57cf2be Sidecar tables define-or-refuse on order-ambiguous declarations
- SC4010 refuses tabled types gathered from multiple declaration sites, naming every site; SC4011 refuses conditional and mapped types with a point-at-one-declaration teaching
- Spread-composed unions flatten depth-first in source order; duplicate arms across constituents keep the first occurrence
- Conformance fixtures pin cross-file payload order, a global-shadowing enum member, and alias transparency on both emissions
- Contract facts now collect across the program's source files, and type-only modules join source_hash/build_id
2026-07-23 17:59:14 -05:00
Chris Tate 9d811bf7b5 Pin declaration-order conformance and define-or-refuse for order-ambiguous sidecar inputs
- New contract-order conformance fixture (both emissions): union arms anti-alphabetical with payload records declared in a separate file (import order never perturbs table order), an anti-alphabetical enum with a global-shadowing "Infinity" member, and a union referenced through a type alias (the table derives from the aliased declaration; the alias adds no entry and no reordering).
- Contract facts now scan the whole program graph, not just the entry: type-only modules join (they have no runtime edge, so they ride the program's source files rather than moduleOrder), non-entry modules anchor after the entry in bytewise path order, and the identity hashes cover type-only modules so contract-bearing edits always move source_hash/build_id.
- SC4010: a tabled or designated type whose members gather from multiple declaration sites (interface merging, module augmentation, a same-name exported type in another module) refuses with every site named file:line.
- SC4011: a conditional or mapped type producing a tabled/designated type refuses with its own teaching.
- Union composition (type Msg = A | B where A/B are kind-tagged unions) is allowed and pinned: arms flatten depth-first in source order, each constituent in its own declaration order, and an arm name appearing in several constituents keeps its first occurrence; a repeat among one declaration's own inline arms still refuses.
2026-07-23 17:57:09 -05:00
Chris Tate b2b880e462 Record order-parity baselines for the generics-frontier fixtures
- Baselines added for corpus 2550-2555 (plus the previously unrecorded 2490-2500 entries the sweep now sees); no recorded entry changed.
- tests/diagnostics/generics.ts keeps its alias/annotation sections as reached COMPILING bodies (their absence from the snapshot is the point), fixing the dangling calls the earlier edit left.
2026-07-23 17:51:13 -05:00
Chris Tate f1b0048325 Structured trap teachings: the library sink message grows a versioned encoding
- A library-mode trap that carries a diagnostic code and/or the trapping symbol is assembled as 0x01 text 0x1F code 0x1F symbol [0x1F remediation]: the teaching text leads so plain-text hosts degrade gracefully, the whole remediation field is absent when the profile supplies none, and the frozen sink signature is untouched — all structure lives in the message bytes. The compiler assembles the buffer once at export resolution (library/trap-teaching.ts), both backends emit the same bytes, and the runtime funnel carries them opaque; the first wired site is the inbound-bytes host-contract trap (new runtime code SC4010), naming the trapping export's C symbol.
- The profile's determinism riders now feed the encoding: teachings gains a remediations sibling, both keyed by code, with keys validated only as tokens free of the reserved bytes (SC space stays the compiler registry's; embedder codes are embedder-prefixed) and values refused at load (SC4001) when they contain 0x01 or 0x1F.
- The escaped-exception renderer honors the verbatim rule: a thrown string or Error message that already begins with 0x01 reaches the sink byte-for-byte — no "Uncaught " prefix, no added newline — which is how facade-authored structured teachings ride the throw channel; everything else keeps the baseline shape, whose printable first byte is what makes the marker unambiguous.
- New K11 conformance fixture (tests/library-mode/teach) drives all of it through a real C host on both emissions: exact structured byte layout via the spec's parse rule, verbatim 0x01-led throws (Error and string), and the printable-first-byte pin on baseline trap and throw messages; library-profile tests cover the remediations round-trip and the reserved-byte refusals.
- The executable lane is untouched: every change sits behind SCR_LIB or the library emission path, verified by byte-identical executable binaries on both backends before and after.
2026-07-23 17:45:44 -05:00
Chris Tate e528169a37 Keyed record writes take the literal-key type rule
- `o[k] = v` whose key identifier's type proves one literal — a keyof-bound parameter inside a generic instance, or a literal-typed const — lowers to a static field write, mirroring the read side.
- Literal-UNION keys keep the fence (a runtime-keyed write needs an index signature), with the instantiation context naming the binding.
- Fixture 2555 (writes, read-modify-write, literal-typed key consts, per-literal swaps), byte-identical vs Node on both backends.
2026-07-23 17:41:18 -05:00
Chris Tate ced1822c24 Destructuring assignment targets, class-instance sources, class rest, and accessor defaults go static
- Nested patterns and member targets in assignment position, with JS's reference-before-value evaluation order pinned
- Class-instance sources call getters exactly once per element; a latent double-call in the accessor-default path is fixed
- Class rest packs the inheritance chain in Node's key order, fencing where enumeration can't be reproduced
- Fixtures 2536-2540 for the promotions; 2530-2535 and 2541 pin the already-static declaration-position surface

# Conflicts:
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-07-23 17:32:49 -05:00
Chris Tate 057ac2cea2 Pin corpus coverage for the already-static destructuring surface
- 2530-2535 and 2541 lock in the destructuring forms the static tier already compiled but the corpus never pinned: object/array/tuple declarations (renames, defaults, holes, nesting, fresh rest tails), the options-object parameter pattern (element and whole-pattern defaults, tuple/rest parameter patterns), for-of heads (containers, defaults, rest, existing bindings), object rest freshness and key order, assignment basics (swaps, chains, expression value), and evaluation order (RHS once, elements left to right, lazy defaults that see earlier bindings).
- All byte-identical against Node under both backends, and each reports 100% static coverage.
2026-07-23 17:27:33 -05:00
Chris Tate 385b0a9199 Promote destructuring assignment targets, class-instance sources, class rest, and accessor defaults to the static tier
- Destructuring assignment now takes nested patterns (`({ p: { q } } = src)`, `[[a], b] = t`) and property/element targets (`[c.x, box.vals[i]] = arr`, `({ a: rec.f } = o)`, rest into members) — receivers temp at their pattern position, JS's reference-before-read order; defaults on member targets test against the target's own type. Defaults on nested targets keep a named fence (no single binding type to test against).
- Class instances destructure in assignment position like they already did in declarations: field slots and getter calls per element via the same fieldGetExpr dispatch, defaults, renames, and member targets; methods and undeclared names keep their pointed fences.
- Rest over class-instance sources packs the remaining instance FIELDS into a fresh record (JS's CopyDataProperties copies own enumerable properties — never prototype methods/accessors, matching the checker's rest type), in declarations and assignments; non-public fields, runtime-provided chains (Error/EventEmitter/stream), and key orders the packed shape cannot reproduce fence instead of diverging.
- Defaults on destructured getter results now lower (record and class accessors alike), with the getter result temped so the default's undefined test never calls it twice; numeric-literal pattern keys (`const { 2: x } = o`) fold to JS's canonical property name.
- Corpus 2536-2540 pin the new forms byte-identically against Node on both backends; the destructuring-fences diagnostics program keeps the honest residue (method extraction, non-public rest fields, nested-target defaults, index-signature rest).
- The ts7 order-parity baseline re-record backfills the entries the released file was missing (2490-2500 included) alongside the new fixtures; no existing entry changed.
2026-07-23 17:27:25 -05:00
Chris Tate ce0dc9ee70 Generic-signature annotations monomorphize their function initializers
- `const g: Mapper = (x) => x` under `type Mapper = <T>(x: T) => T` (aliases and inline generic function types alike) registers like `const g = <T>(x: T) => x`: the type parameters come off the annotation's one call signature, whose symbols are exactly what the checker types the initializer's parameters by (bindingContextualGenericFnNodeOf).
- Function-expression initializers, pinned-value uses, aliases of the annotated binding, and multi-parameter signatures with generic callbacks all ride the existing instance table.
- The SC2001 generic-signature message now names every binding shape that monomorphizes; escapes with no statically enumerable instantiations (generic-signature parameters, stored results) keep the fence with that precise wording.
- Fixtures 2553 (alias and inline annotations, function expressions, pinned values) and 2554 (keyof + aliases + signature bindings + interface methods composing), byte-identical vs Node on both backends.
2026-07-23 17:26:56 -05:00
Chris Tate f66a4e0bf2 Generic methods through interface-typed receivers monomorphize against the proven class
- `const r: Repo = new MemRepo()` over an interface whose every member is a generic-callable method keeps the initializer's CLASS representation (genericIfaceBindingKeepsClass): the record shape maps empty — generic members are excluded — so the width copy would drop the class the calls dispatch against, and in JS the binding IS the instance.
- Calls like `r.get(...)` resolve through exactInstanceClassOf to a class generic-method call on the exact class: `this` works, state mutates on the one real instance, and record-typed USES width-coerce at the use site instead of the declaration.
- Receivers with no provable class (parameters, `let`, produced values) keep the fence, now naming the actual blocker: static dispatch needs a const bound to its `new` expression.
- Fixture 2552 (stateful implementations, two classes, block scope, casts back to the class, record-typed uses), byte-identical vs Node on both backends.
2026-07-23 17:23:49 -05:00
Chris Tate 0386d8c00f keyof-constrained generics monomorphize per literal key; generic-fn aliases register their target
- Instantiations carry ts-level bindings alongside the mapped IrTypes: a `K extends keyof T` parameter keys its instance on the bound literal (no cross-literal sharing — the bodies read different fields), and literals forward through generic-to-generic calls.
- `T[K]` inside instance bodies resolves through the bound checker types (mapBoundIndexedAccess via the new resolveTypeParamTs hook), and `o[k]` reads whose key TYPE proves one literal — a keyof-bound parameter or a literal-typed const — lower to static field reads.
- `const h = id` registers the target's GenericFnInfo under the alias's symbol (chains, block scope, pinned values, and calls all resolve like the target's own name); non-const/reassigned aliases fence by name, and unpinned VALUE uses keep their fence at the reference.
- Fixtures 2550 (keyof/pick shapes, forwarding, runtime keys, literal-typed key vars) and 2551 (alias chains, contextual pinning, annotated generic aliases), byte-identical vs Node on both backends.
2026-07-23 17:20:03 -05:00
Chris Tate aa8d31c3cd SC2001 splits into named type-shape fences
- SC2005 generic call signatures, SC2006 index-signature shapes, SC2007 overloads, SC2008 unresolved intersections, SC2009 supported shapes over an unsupported component with the component named
- Stdlib nominal types reroute to the SC2020 story instead of a duplicate code
- SC2001 keeps only bigint/symbol, constructor objects, and unresolved library generics — its registry name now says so
- Five new diagnostics programs pin one frame per code; manifest entries added; zero behavior change to accepted programs

# Conflicts:
#	tests/harness/__snapshots__/regex.ts.txt
2026-07-23 17:17:31 -05:00
Chris Tate e5d4825a77 Private statics resolve through provably-exact class values
- X.#m() calls, const-bound class expressions, decorated names, and const aliases all reach static #private members when the receiver provably holds the declaring class
- The write path's exactClassOfReceiver and leaf-class rules extend to the call and read paths through one shared predicate
- Slots that can hold a descendant still fence; the read path gains the subclass-spelling fence the other paths had
- Fixtures 2520-2523 on both backends
2026-07-23 17:11:48 -05:00
Chris Tate 059d603786 Evolving-any arrays keep their handle-element lowering at method calls
- tsc's evolving-array analysis answers the pushed element type at later call sites; the monomorphizer trusted it while the receiver value lowered as array<jsval>, producing an ill-typed call the validator rejected
- The receiver value's element type now wins across the array method family, riding the explicit-any[] handle path; unannotated locals and file-scope aliases adopt the same spelling
- .find on handle-element arrays fences honestly instead of ICEing
- Fixtures 2510-2513 under --dynamic, byte-identical on both backends
2026-07-23 17:11:30 -05:00
Chris Tate 0685c867e9 Eleven coded stops on the formatter-runtime chain fixed at the compiler
- T[K] indexed access resolves against instantiations; Object.hasOwn/assign on records and DOM values; runtime-keyed writes to fixed shapes with a key-miss trap
- Regex union arms with instanceof RegExp as the tag test; string | RegExp shapes map
- Island literals gain getters, spreads, and real TemplateStringsArray identity for tagged templates
- JS variadics under --dynamic bind the engine's arguments array; fn(...args) lowers to engine apply
- Fixtures 2470-2476 on both backends; SEMANTICS entries 385-390

# Conflicts:
#	packages/compiler/src/frontend/types.ts
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-07-23 17:11:29 -05:00
Chris Tate 64bcb304e2 Monomorphize evolved-any array methods on the value's handle element under --dynamic
- 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.
2026-07-23 17:01:32 -05:00
Chris Tate 44cde1510e Split the SC2001 catch-all into named type-fence families
- New codes, minted in badType's classification order: SC2005 values whose type keeps a generic call signature, SC2006 index-signature shapes outside the supported set, SC2007 overloaded function types, SC2008 intersections with no resolved lowering, SC2009 supported container/function/record shapes over a component outside its slot — the SC2009 message names the offending component (Map/Set key-value domains, array/tuple elements, union arms, function rest/params/returns, record members) via describeComponentBlocker/describeRecordMemberBlocker in frontend/types.ts, which mirror mapType's own rules on the failure path only.
- Standard-library nominal types with no lowering at all (Date, ArrayBuffer, WeakMap, the iterator and constructor interfaces) now route to the existing SC2020 story instead of the supported-set recitation; stdlib provenance is checked after the container claims so Map/Set/Promise instantiation failures keep their component story.
- SC2001 keeps the honest remainder — bigint and symbol primitives, constructor objects, and library-derived or unresolved generic shapes — and its registry name now says so; across the diagnostics corpus its rendered sites drop from 57 to 5.
- Every new code flows through the diagnostics registry, the regenerated surface manifest, and coverage-report grouping; five new tests/diagnostics programs pin one rendered frame per code, and the ts7 order-parity baselines re-record to include them.
- Zero behavior change to accepted programs: the differential corpus (900 programs) is untouched and green, and the full suite passes.
2026-07-23 16:55:31 -05:00
Chris Tate 5ba6cffcd4 Private statics resolve through provably-exact class values: const-bound class expressions, class aliases, and rebindable decorated names
- staticCallOn and lowerClassValueProperty fenced every #private static access with a through-a-VALUE receiver, so C.#m()/C.#f on a const-bound class expression, A.#f through a const alias of the class, and Example.#m() under a replacing decorator all died with SC1090 while the direct class-name spelling compiled.
- The static-WRITE path already knew the sound rule (exactClassOfReceiver plus the leaf-class arm); classValueIsExactlyOwn now shares it with the call and read paths: a receiver that provably IS the class, or a class with no strict descendants, always carries the declaring class's brand — the fence stays for slots a subclass can inhabit, where Node throws TypeError.
- Rebindable decorated names ride the leaf arm for free: replacement decorators fence any class with subclasses before minting the rebindable global, so the decoration result is always the declaring class object.
- The read path additionally gains the subclass-spelling fence (reading an inherited private static through a subclass-named binding) that the call and direct-read paths already had.
- Fixtures 2520-2523 pin the four call forms (class-name calls including static field initializers and subclassed declarers, const-bound class expressions with reads/writes/calls, decorated classes under both replacing and void decorators, aliased class values local/module/param) byte-identical vs Node on both backends; the private-members diagnostics fixture repins the residual fence on a descendant-capable slot.
2026-07-23 16:37:51 -05:00
Chris Tate 28c20eff00 2470 declares its one deferred fence (the Object.entries table loop)
- the mockImplementations body defers one statement in static builds (SC2011, never executed) — the @deferred-fences directive keeps the coverage sweep honest
2026-07-23 16:15:46 -05:00
Chris Tate f26e50b808 Re-pin the parity artifacts for the width-narrow and regex-union landings
- order-parity baselines re-record for corpus 2470-2476 (new fixtures only)
- regex.ts drops the RegExp | undefined fence (regex union arms compile)
- spread-fences.ts drops the optional-into-required SC2002 (the checked NARROW lift, divergence 38's stance: the flow traps at runtime where it used to fence at compile)
2026-07-23 15:51:04 -05:00
Chris Tate 50a3b1f9c5 The LLVM tier spells the net autosel-timeout runtime symbols correctly
- LIB_FN_SYMS mapped net.{get,set}AutoSelTimeout to scr_net_{get,set}_auto_sel_timeout; the runtime defines autosel — every LLVM-tier program touching the surface died at link
- The ABI guard gains a table-existence audit: every scr_* string the backend sources can emit must exist in scr_runtime.h as a prototype or extern data symbol
- Fixture 2500 exercises the surface differentially on both backends
2026-07-23 15:48:38 -05:00
Chris Tate 586683ccae Fix LLVM-tier link failure on net autosel timeouts; audit every emittable runtime symbol name
- LIB_FN_SYMS mapped net.getAutoSelTimeout/setAutoSelTimeout to scr_net_get_auto_sel_timeout/scr_net_set_auto_sel_timeout, but the runtime defines scr_net_get_autosel_timeout/scr_net_set_autosel_timeout (the C backend already used the correct spelling), so any program touching net.getDefaultAutoSelectFamilyAttemptTimeout on the LLVM tier died at link with undefined symbols.
- The ABI guard could not see this: the literal-declare source scan only checks fully-literal declare strings, and the emitted scan's corpus slice never exercises the net autosel surface — a table entry whose fixture doesn't exist was invisible from both directions.
- llvm-runtime-abi.test.ts grows a third, table-driven direction: every scr_* name the backend sources can ever emit — the static string tables plus every literal @scr_* template reference (interpolated per-type families excluded) — must exist in scr_runtime.h as a prototype or extern data symbol, so a two-string name skew now fails at test time instead of at the user's link step.
- parseHeader additionally collects extern data symbols (scr_emitter_vt, scr_error_vts) so vtable-global references audit cleanly.
- New corpus fixture 2500-net-autosel-timeout.ts round-trips the default attempt timeout (set then get, integers >= 10 to stay clear of Node's clamp) and is byte-identical vs Node through both backends.
2026-07-23 15:47:44 -05:00
Chris Tate 1ea08e4f80 Helper returns synthesize helpers_<name>: the member slot is the helper name
- The return shapeRef now seeds container 'helpers' with the helper name as the member, so an inline-record helper return tables helpers_<name> instead of helpers_<name>_return; parameter naming (helpers_<name>_<param>) is unchanged
- The contract fixture gains 'extent', a helper returning an inline record, pinning the synthesized name helpers_extent in the type table and the value-kind helper return with the arena bit
- The anti-alphabetical suite asserts the new struct entry and helper row on both emissions; V13 byte-determinism stays green
2026-07-23 15:42:03 -05:00
Chris Tate f72a69e4b9 The formatter-runtime chain: eleven coded stops fixed at the compiler
- T[K] resolves against record bindings, Object.hasOwn/assign lower over records and the DOM, fixed shapes take runtime-keyed writes with the miss trap, and string|RegExp unions narrow by instanceof
- the width family gains the checked NARROW lift and the tuple-arm literal route (the option-table shapes)
- island literals complete: get accessors, plain spreads, tagged templates with .raw, jsval ??, and call-time fence deferral for unlowerable members (lambda poisons defer too)
- JS variadic rests under --dynamic bind the engine arguments array and re-invoke through apply; dyn values marshal into the island as the deep copy
- corpus 2470-2476 pin every landing against the Node oracle on both backends
2026-07-23 15:32:37 -05:00
Chris Tate 0334622abd The contract sidecar emits beside every sidecar-declaring library build
- All twenty schema fields: declaration-ordered type tables, wyhash-64 build_id, descriptor families
- Deterministic byte-equal emission on both backends, validated against rules V1-V14
- Identity getters synthesize as constants: pre-init and post-poison reads match the sidecar
- A computed determinism attestation from a conservative ambient-surface scan
2026-07-23 15:27:51 -05:00
Chris Tate 7cfd08295c No-arm unit comparisons answer constants instead of trapping
- A union lacking null or undefined compares against that literal as a constant, both orders
- Effectful operands still evaluate exactly once; switch unit cases ride the same lowering
- The external adversarial corpus stands at 52 of 53 byte-identical
2026-07-23 15:27:35 -05:00
Chris Tate 5eecd268ef Pin the sidecar contract: anti-alphabetical fixtures and the V1-V14 suite
- the contract fixture declares every order anti-alphabetically (type names, fields, enum members, union arms, msg arms, helpers) and the harness asserts the exact orders on both emissions
- its probe reads the identity getters before init and after a poisoning trap and the harness compares both reads to the sidecar's build_id (V12 plus the ratified exemption, end to end)
- V13 rides two independent identical invocations compared hash-equal; V11 rides nm both directions over the prefix
- the contract-attest fixture pins tuple-returning init/update, subscriptions presence, the default <out>.contract.json path, the empty absent forms, and Date.now demoting deterministic to false
- the validator suite passes a full-vocabulary conformance document and catches one targeted mutation per rule, plus SC4009 refusal coverage through compileLibrary
2026-07-23 14:44:57 -05:00
Chris Tate b1af5f62ec Library profiles grow the ask-2 sidecar section over wyhash-64 identity
- profile.sidecar declares the echoed constants (wire/abi/snapshot), the identity-getter symbols, the model/msg designations, and the profile-selected "module-graph" source-hash contract; presence turns contract emission on
- wyhash.ts implements wyhash-64 final_version_3 (BigInt, vector-pinned) with the length-prefixed framing the schema's build_id definition requires
- the profile's exact bytes ride the resolved LibraryProfile (build_id input 2), getter symbols join the pairwise-distinct claim set, and unknown fields inside the section refuse as SC4001
2026-07-23 14:44:24 -05:00
Chris Tate 8d2b3bb2e0 No-arm unit comparisons answer constants instead of trapping
- lowerUnitComparison folds ===/!== against a union lacking the unit arm to the constant answer, both operand orders
- a non-droppable operand still evaluates exactly once, riding a throwaway tag test
- union-switch case null / case undefined take the unit-comparison lowering, so a lacking arm never matches
- the unionEq fallback had coerced the literal through the stranded-arm trap, throwing where Node answers false
- corpus 2490-2494: the find-miss repro, every strict and loose spelling, switch unit cases, effect preservation
2026-07-23 14:34:41 -05:00
Chris Tate 5197893468 Recursive record types compile statically
- Self-referential interfaces, mutual recursion, and recursive unions map to knotted shapes
- Cyclic values collect under the cycle collector; JSON.stringify throws V8's exact circular error
- console.log prints Node's circular reference markers, retiring a documented divergence
- Checked casts validate recursive shapes with path-exact failures
2026-07-23 13:54:51 -05:00
Chris Tate cb00ff773c Pin recursive-shape checked-cast failure paths in the dyncheck harness
- a lying cast three knots deep renders the full path ($.children[0].children[0].label)
2026-07-23 13:26:12 -05:00
Chris Tate b49052a389 Recursive record types compile statically as named recursive shapes
- mapType back-references mint placeholder shapes/unions finalized at frame exit; identity is per checker type, and context-sensitive (generic/mixin) knots stay fenced
- every type walk survives cyclic shape graphs: coinductive JSON/dyn-safety predicates, guarded formatIrType/jsvalLiftable, cycle headers via the existing collector fixpoint on both backends
- JSON.stringify throws V8's byte-exact circular TypeError (hop lines, ellipsis rule); cyclic values crossing into checked-dynamic slots trap instead of hanging
- console.log/util.inspect render <ref *N>/[Circular *N] exactly (SEMANTICS 129 resolved; depth:null lowers) and deepStrictEqual terminates through Node's pair memo
- corpus 2480-2488 green on C, LLVM, and the sanitized RC-audit lane, which proves child->parent cycles collect
2026-07-23 13:24:13 -05:00
Chris Tate ee57575c18 Parallelize CI: flavor and shard matrix with within-file corpus slicing
- Six jobs: plain/san across three sha1-keyed case shards; an aggregate check keeps the old name
- SCRIPTC_TEST_SHARD slices the corpus harnesses; unset means everything
- Two vitest passes per job so file-granular sharding cannot drop corpus slices
2026-07-23 12:26:22 -05:00
Chris Tate f2637da4ea Bundler-emitted CJS packages type their named exports
- A canonical-table rewrite recognizes getter-table and star re-export plumbing
- Chaseable getter bodies type by their resolved values; the lexer name set is the contract
- Consumer-anchored errors degrade the opted-in package with a note instead of gating
- Two lowering ICE classes fixed; untyped packages stay flag-invariant
2026-07-23 12:26:22 -05:00
Chris Tate 6a4a94fa26 Pin the getter-table shapes: npm cases 2465-2469
- 2465-2468 byte-match Node fully static: the esbuild __export table, the __reExport star, the tsc __exportStar barrel, and the defineProperty getter family
- 2469 pins consumer-anchored degradation: a type-only surface name drops exactly the named package to the island with the site-count note
- auto opts a getter-table bundle in (the marker relaxation), and the untyped-package stub pin replaces the accidental inferred-surface bonus
- the island differential lane excludes the opt-in-only cases by design
2026-07-23 11:47:44 -05:00
Chris Tate e8f04b9054 Parallelize CI: flavor x shard matrix with within-file corpus slicing
- ci.yml runs test (plain|san, 1..3/3) on macos-15; an aggregate job keeps the old "test" check name for anything pinned to it
- each job runs vitest twice: --shard=i/3 over everything but the corpus lanes, then the four corpus lanes with only their case slice — a file lands in exactly one --shard slice, so mixing the axes would silently drop cases
- tests/harness/shard.ts: SCRIPTC_TEST_SHARD="i/n" slices case lists by sha1(name) mod n — stable across corpus growth, every case in exactly one shard, unset means everything
- differential, llvm-differential, npm, and server harnesses slice through it; the llvm tier-floor assertion checks only this shard's floor programs
- shard.test.ts pins the partition contract (union exact, disjoint, key-stable, env-driven default) and stays green with the job-wide env set
2026-07-23 11:13:11 -05:00
Chris Tate 08dc012f95 Retry fs.watch triggers until the event lands: the 1751 flake dies
- Node-on-macOS backs fs.watch with an FSEvents stream that starts asynchronously, so both fixtures' single delayed touch could slip into the startup window and vanish, the persistent watcher holding Node's loop until the 300s hang detector fired
- 1751 rewrites the target on a 50ms interval until the first delivery closes everything; the options-record pins (three-arg form with undocumented keys, options-only form, readline crlfDelay) and the exact stdout bytes are unchanged
- 1564 gets the same treatment in both phases: interval appends for the change phase, name flipped out of and back into existence for the rename phase
- a 600-kick bound turns a genuinely dead watcher into a loud nonzero exit instead of a silent hang
- the compiled side never raced (kqueue/inotify register synchronously at the fs.watch call), so only the Node oracle behavior changes
2026-07-23 10:22:30 -05:00
Chris Tate 0803a0fcd3 Library mode: compile a TypeScript module set to a linkable archive
- scriptc build --lib --profile emits ccc wrappers, init/sink/reset/collect entries, and a static archive
- async_free is structural: the async and event-loop units never link, symbol-audit proven
- Every runtime trap routes through one funnel; the sink contract covers both emissions
- The K-fixture conformance matrix runs a real C host against both backends
2026-07-23 09:42:26 -05:00
Chris Tate b5e3d019fc Rename the capability: library mode, never "core", surface and internals
- CLI: the core verb becomes `scriptc build --lib --profile <p.json>` (no positional; profile names the entry); artifact renames to <name>.lib.a with .lib.ll/.lib.c/.lib.ir.json siblings
- SC4xxx diagnostic text and hints say library, never core; trap-message strings likewise (LIBRARY RC AUDIT, library reset registry, library inbound bytes)
- internals: compileLibrary/compileLibArchive, IrModule.lib + IrLibSection/IrLibExport, moduleLibAsyncSurface, libRoots, loadLibraryProfile/LibraryProfile under src/library/, frontend/lib-exports.ts, emitLibEntries/emitLibDefs
- runtime: scr_core.c -> scr_library.c with scr_library_* symbols and the SCR_LIB macro (scr_lib_* was taken by the stdlib unit); scr_lib_session_cleanup
- tests: tests/library-mode/ fixtures (entries lib.ts), library-*.test.ts harness files
2026-07-23 09:24:44 -05:00
Chris Tate 85ad8eba44 Console prints every inspectable shape; union literals widen per-field
- console.log routes non-scalar arguments through the static inspect machinery
- Union arguments dispatch per arm at runtime; string arms print raw
- Object literals widen per-field into a uniquely-fitting union arm
- The limitations page documents the type surface
2026-07-23 09:14:02 -05:00