Skip to content

-mm=own: @keeps/@borrows parameter markers and own generator fixes - #622

Merged
ASDAlexander77 merged 2 commits into
mainfrom
own-param-markers
Oct 19, 2026
Merged

ASDAlexander77 merged 2 commits into
mainfrom
own-param-markers

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Decision B toward an own default library (after #611). Spec: tslang/docs/superpowers/specs/2026-10-19-own-param-markers-design.md. DefaultLib companion: ASDAlexander77/TypeScriptCompilerDefaultLib#37

  • Markers. @keeps("p") / @borrows("this","p") say what a function keeps of, or what its generator state borrows from, its arguments. They are printed into __decls, carried onto dynamic-import globals, and checked: against the body, and across family overrides (errors name the parameters). Unknown, repeated or empty markers are errors.
  • Generators under own. A narrowed generator local is a view of its state field, not an SSA copy (it was stale after a yield). Yielded state fields are not released by the state. A non-owned parameter's retain in a non-borrowing box is skipped (fixed a silent exit-127 miscompile).
  • next() is the caller's (user ruling): an iterator's next() result and a generator maker's state are fresh, through the Iterator interface or another module; only next(), not every unresolved call.
  • Another module's generator state is released without its fields: only the .captured box's cells, and their values unless the maker says @borrows.
  • OwnedReturnConsumptionPass only matches class methods (a class next was confused with a generator's).
  • Tests: own/own_param_markers, own_generator_locals, own_iterator_next, six own_err_* cases, and cross-module export_own_markers / import_own_markers* under gc, rc and own.

Merged with main (#618-#621); one conflict in walkBorrowed, kept the bounded-result exclusion. Full suite: 4813/4813 (Release, Windows, DefaultLib rebuilt for gc/rc/none/own).

Not here: clone().resize temporary UAF in the own DefaultLib (bug on main); @borrows for a non-generator function whose result borrows an argument.

🤖 Generated with Claude Code

ASDAlexander77 and others added 2 commits October 19, 2026 23:40
- @keeps("p") / @borrows("this","p") declare what a function keeps of, or
  borrows from, its arguments; they carry across modules through __decls and
  dynamic imports, and are checked against the body and family overrides.
- A narrowed generator local is a view of its state field, not an SSA copy.
- Under own, an iterator's next() result and a generator maker's state object
  are the caller's, even through the Iterator interface or another module.
- Another module's generator state is released without its fields.
- Yielded state fields are not released by the state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	tslang/lib/TypeScript/OwnershipInferencePass.cpp
@ASDAlexander77
ASDAlexander77 merged commit c244279 into main Oct 19, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the own-param-markers branch October 19, 2026 23:07
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