Repository navigation
-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
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TSLANG 188.
next()(orthrow()) called by hand throughGenerator<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-typednext/throwfield 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-writtennext()returning its own field is refused at compile time, as before.(...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 moduleconstinitializer under own.Tests:
00own_generator_next_by_hand.ts,00function_value_rest_adapter.ts(gc, rc, own);00function_value_adapter.tsgains own legs; diagnostic-locationown_function_value_adapter.tsnow pins the escaping case. Full local suite: only the 10 known local failures.🤖 Generated with Claude Code