Skip to content

TSLANG 207/208: generic literal receivers, any to number tuples, own optional fields, rest of T | null, s32 members for interfaces, own literals to keeping callees - #1043

Merged
ASDAlexander77 merged 5 commits into
mainfrom
leftovers-1126
Nov 27, 2026
Merged

ASDAlexander77 merged 5 commits into
mainfrom
leftovers-1126

Conversation

@ASDAlexander77

@ASDAlexander77 ASDAlexander77 commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Leftovers of TSLANG 195, 196, 198 and 205 (TSLANG 207), and the two cases 207 left open (TSLANG 208).

TSLANG 207

  • Generic call with a literal (205). takeG({ produce: () => 44 }, 1.5) failed with "can't assign '() => s32' to '() => number'". With the arguments the other way round, D came out as 1.5 | s32. Now the literal is typed by its parameter once the other arguments give D. To infer D, inferObjectLiteralArgumentReceivers reads the literal's members one by one without creating them. A member created at that stage kept the () => s32 type it was first made with.
  • any to an object type of numbers (195). <{ code: number }>a, where the any holds { code: 7 }, threw "the object's fields are not those of type". Layouts with s32 in place of up to three number fields are now read and converted (castAnyToTupleOfNumbers). Not under -mm=own, where merging the values from those reads is a second reference: there the cast still throws. That case is tested in 00tslang_issue_207_any.ts only (not in 00any_to_tuple.ts, which the wasm runner also runs under own).
  • Missing optional field under -mm=own (196). const o: { disc?: false; cb: Cb } = { cb } failed with "a value that borrows a field cannot be stored". The literal is now built with the missing optional fields set to undefined, so it already has the receiver's layout and isn't converted out of its slot.
  • Rest of a T | null (198). const { a, ...rest } = u, and the assignment form, failed with "the rest of a value of type 'null | T' can't be taken". The rest is now taken from T, the same way the pattern's other names read T's fields.

TSLANG 208

  • s32 function member given as an interface's number member. const t = { produce: () => 45 }; const o: Options<number> = t (and read(t)) failed with "field "produce" not matching type". Per the 11-26 ruling, integer literals stay s32 and the function is adapted: the interface clone gives such a field the member's type (getInterfaceCloneFields) and the cast widens the result. A field of a constant object is its function, named (fewerParametersThunk), so no box is made and -mm=own accepts it.
  • Under -mm=own, a tuple or object literal given to a callee that keeps it. k.keepOne(["a" + i, i]) and k.keepObj({ s: "b" + i, n: i }) failed with "this function does not own it". A literal of new values or string constants given to a call now goes into an owned local of its own (ownedLiteralArgument), as const t = [...]; k.keepOne(t) does. Borrowing records, closures, and literals inside && / ?: are left as they were. 2M calls, keeping or borrowing, stay at about 5 MB.

Still not done (in TSLANG_ISSUES 208):

  • Under -mm=own, an object in a let cast to such an interface (its function is adapted through a box: "second reference"). A const object works.
  • Under -mm=own, a literal argument directly in a try body. A declared local there is refused the same way.

Tests: 00tslang_issue_207.ts, 00tslang_issue_208.ts (all models), 00tslang_issue_207_any.ts (gc, rc, none). Windows ctest 9893/9893.

🤖 Generated with Claude Code

ASDAlexander77 and others added 3 commits November 26, 2026 22:16
…ic call's receiver (not working yet)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uples of numbers, own optional fields, rest of T | null

- takeG({ produce: () => 44 }, 1.5): the literal is typed by its parameter once the other arguments give the type
  parameter; inferObjectLiteralArgumentReceivers reads its members without making them (one made then kept `() => s32`)
- <{ code: number }>a of an `any` holding { code: 7 }: layouts with s32 in place of up to three number fields are read
  and converted (castAnyToTupleOfNumbers); not under -mm=own
- -mm=own: a literal leaving out an optional field of its tuple receiver (`{ cb }` for `{ disc?: false; cb }`) is made
  with it, undefined, instead of converted out of its slot ("a value that borrows a field cannot be stored")
- the rest of a `T | null` (declared and assigned) is T's

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d object literals given to callees that keep them

- `const t = { produce: () => 45 }; const o: Options<number> = t` (and `read(t)`): the interface clone gives a
  this-less function field that does not match the member the member's type (getInterfaceCloneFields), and the cast
  adapts it, widening the s32 result (user ruling 11-26: adapt, literals stay s32). A field of a constant object is
  its function, named (fewerParametersThunk), so no box: -mm=own takes it too.
- -mm=own `k.keepOne(["a" + i, i])`, `k.keepObj({ s: "b" + i, n: i })`: "this function does not own it". A literal
  of new values or string constants given to a call goes into an owned local of its own (ownedLiteralArgument), as
  `const t = [...]; k.keepOne(t)` does. Borrowing records, closures and literals inside `&&`/`?:` are left as they
  were. 2M calls (keeping or borrowing) stay at about 5 MB.
- 00any_to_tuple.ts: the s32 case is only in 00tslang_issue_207_any.ts (the wasm own run failed on it: under own the
  cast still throws).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77 ASDAlexander77 changed the title TSLANG 207: generic literal members typed by their receiver, any to tuples of numbers, own optional fields, rest of T | null TSLANG 207/208: generic literal receivers, any to number tuples, own optional fields, rest of T | null, s32 members for interfaces, own literals to keeping callees Nov 26, 2026
ASDAlexander77 and others added 2 commits November 26, 2026 23:27
…ead on Linux)

User functions are global symbols, so a program's `read` is the `read` Boehm GC calls while it starts
(GC_get_nprocs in GC_init): the Linux debug exe segfaulted before main ran.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wn literals and locals in a try body

- `let t = { produce: () => 45 }; const o: Options<number> = t` (a `const` as well): the interface's slot calls the
  field through its thunk, as for a closure field, and the thunk converts the s32 result to the member's number
  (isResultWideningFieldFunction). The object is given as it is, with no copy and no boxed adapter, so -mm=own
  takes a `let` too (it refused the box: "a value takes a second reference").
- -mm=own, directly in a `try` body: `k.keepOne(["t" + n, 0])` and `const t = ["u" + n, 1]; k.keepOne(t)` were
  refused ("an object literal that holds a value it owns is moved only into a local"). The hoisted local is given
  its value by a store right before its retain (slotDeclarationStore); that retain is now the literal's, as an
  initializer's is (recordRetainOf). ownedLiteralArgument hoists its local there as a declared one is.

Still open (TSLANG_ISSUES 208): a move in the middle of a multi-statement try body, and a kept parameter leaked when
its callee throws before keeping it (pre-existing, class instances too).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 6bf01b9 into main Nov 27, 2026
8 checks passed
@ASDAlexander77
ASDAlexander77 deleted the leftovers-1126 branch November 27, 2026 00:22
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