Skip to content

TSLANG 211: leftovers of 193/194/205, own conversions and for...of literals, own past-end check - #1045

Open
ASDAlexander77 wants to merge 3 commits into
mainfrom
leftovers-1127
Open

ASDAlexander77 wants to merge 3 commits into
mainfrom
leftovers-1127

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Leftovers of TSLANG 193, 194 and 205, plus old "still open" notes that a triage re-ran against current main (TSLANG 211).

Fixed

  • 193. A discriminant read from an exported const (export const KA = "a"; run({ kind: KA, method(a) {...} })) failed with "can't be stored". By the 09-13 ruling an exported const is stored as a let, but its type was widened to string along with that. It is never assigned, so it now keeps its string literal type, as in TypeScript.
  • 194.
    • v.msg of { valid } | { valid; msg } was read as if the value were the first member that has msg, which reads past the end of a smaller member. It is now read from the member the value holds, and gives the type's empty value for a member that lacks the field.
    • "msg" in v now works on a union of object shapes (it was "only a union of interfaces is") and narrows the same way as for interfaces.
  • 205. { x: string } & any is any when any is written in the intersection (never & any stays never; X & unknown is X). It used to be never. The tsc test that looped with the first attempt now stops at once, on an unrelated error.
  • Under -mm=own, converting a variable that holds a string to another object type (const u = { n: 1, name: "x" + i }; const p: { n: number; name: string } = u) failed with "a value that borrows a field cannot be stored". The new object takes a copy of each string, is built in a slot, and goes into a local of its own. That only happens when every other block-holding field is new or constant; otherwise it stays a borrow, as before. 2M conversions stay at about 6 MB.
  • 137, under -mm=own. for (const o of [new A(), new B()]) failed with "moved only into a local". The literal now goes into a local of its own.
  • 152, under -mm=own. An element stored past the end through a local over a parameter's array (let src = order; src[n] = v), or through a Shared payload, was written past the end of its block, corrupting the heap. It now throws a RangeError (or hits an assert without the default library). This is not JavaScript's behaviour, which grows the array: growing through such a local needs a new own rule (a push through it is refused too).

Tried and taken back out (each failed tsc-clean tests in the sweep; recorded in TSLANG_ISSUES 211):

  • Record<string, T> as a dictionary: a constraint T extends Record<string, X> no longer accepted object literals.
  • Deferring { x: string } & T until T is known: inference failed elsewhere.
  • An error for overloads in a declared class: tsc-clean tests with such overloads used to compile.
  • Making the partial-field read a TypeScript error: tslang doesn't follow every narrowing (switch (true) clauses, truthy discriminants) that tsc-clean code relies on.

Not done: listed in TSLANG_ISSUES 211, with repro files from the triage. This includes own <{ code: number }>a of an s32 any, 132, the Object.* gaps, 191, and the own loop and closure shapes.

Checks

  • Windows ctest: 9918/9918.
  • tsc compiler-tests sweep: 3710 pass, the same as a baseline run with the pre-batch compiler, with no test changing status either way.
  • Leak probes under own: about 5–6 MB flat.
  • DefaultLib, rebuilt with this compiler: release tests pass in all models.
  • Linux (WSL): the 207-211 tests pass with release and debug programs; the own probes stay at about 6 MB.

🤖 Generated with Claude Code

ASDAlexander77 and others added 3 commits November 27, 2026 01:58
… literal type; union field missing on a shape is an error; in for shape unions; X & any; generic intersections

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…red class overload error, own past-end check, tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eclared overload error (tsc sweep regressions); partial union field read from the member held; any only when written

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant