Skip to content

-mm=own: a generator's next() by hand gives back what it yielded; a function read at run time is adapted to another function type (TSLANG 188) - #1026

Merged
ASDAlexander77 merged 2 commits into
mainfrom
tslang-188
Nov 24, 2026
Merged

ASDAlexander77 merged 2 commits into
mainfrom
tslang-188

Conversation

@ASDAlexander77

@ASDAlexander77 ASDAlexander77 commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

TSLANG 188.

  • -mm=own: a generator's next() (or throw()) called by hand through Generator<T> never released what it yielded, so a generator of strings grew the heap with every call (pre-existing; for-of did not leak). OwnershipSignaturePass already takes the { value, done } for fresh (isIteratorNext), but MLIRGen marked only a plain call's result owned. A call through an interface's function-typed next/throw field returning that record is now marked owned under own (mlirGenCall). Four probes went from 120-274 MB at 3M iterations to a flat ~48 MB. Checked: a yielded string kept past the record (last = g.next().value, keep.push(...)) runs correctly and flat; a hand-written next() returning its own field is refused at compile time, as before.
  • -mm=own: a function read at run time given as another function type (an object literal's field for (...args: A) => T, a callback with fewer parameters through a variable) was refused. It now goes through the same boxed adapter as in the other models (functionValueAdapter). A capturing closure, and an adapted value that would escape its caller, are refused by the own rules, now at the adapter's source location instead of <unknown>:0.

Still open (TSLANG_ISSUES.md 188): own refuses a generator yielding objects it got from another iterator in every shape (yield*, for-of, next() by hand) - own inference work; an adapted function value in a module const initializer under own.

Tests: 00own_generator_next_by_hand.ts, 00function_value_rest_adapter.ts (gc, rc, own); 00function_value_adapter.ts gains own legs; diagnostic-location own_function_value_adapter.ts now pins the escaping case. Full local suite: only the 10 known local failures.

🤖 Generated with Claude Code

ASDAlexander77 and others added 2 commits November 24, 2026 20:12
…ed (TSLANG 188)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e through the adapter (TSLANG 188)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77 ASDAlexander77 changed the title -mm=own: a generator's next() called by hand gives back what it yielded (TSLANG 188) -mm=own: a generator's next() by hand gives back what it yielded; a function read at run time is adapted to another function type (TSLANG 188) Nov 24, 2026
@ASDAlexander77
ASDAlexander77 merged commit 44c2f20 into main Nov 24, 2026
8 checks passed
@ASDAlexander77
ASDAlexander77 deleted the tslang-188 branch November 24, 2026 21:34
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