Skip to content

-mm=own: union-of-shapes field returned as a borrow; methods throwing objects through a yielding finally (TSLANG 181) - #1018

Merged
ASDAlexander77 merged 1 commit into
mainfrom
tslang-181
Nov 24, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
tslang-181

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Two -mm=own items left after TSLANG 180 (TSLANG_ISSUES.md item 181).

Fixed

  • A field read through a union of object shapes, returned (function getBox(s: Sq | Ci): Box { return s.box; }, 164): "a value is merged from several branches".
    • The field is read once per shape, from the member the union holds (ts.GetValueFromUnionOp, then ts.ExtractProperty). borrowedParam now follows both ops, so the function returns a borrow of its argument, as it does with one shape.
    • Callers may read the result but not store it, again as with one shape.
  • A method that throws an object, called in a try whose finally yields (try { yield 1; w.boom(); } finally { yield 2; }): it stopped at run time.

Still open

  • An override in a subclass that throws an object, called through the base class, is not seen: the check follows the base class's method.
  • for (const s of this.items) yield s in a generator method (158) needs a ruling. The loop keeps the field's array in the generator's state across its yields.

Verified

  • Full ctest on main 2342236: only the 10 failures that also fail locally on main.
  • 00own_union_shape_field_borrow.ts passes under gc, rc, own and none.
  • The diagnostic-location test for the method passes.
  • Storing getBox's result into a field is refused exactly as for the one-shape getter.
  • Under own, peak memory at 3M iterations is no higher than at 300k.

🤖 Generated with Claude Code

…borrow; methods throwing objects through a yielding finally (TSLANG 181)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit b999136 into main Nov 24, 2026
8 checks passed
@ASDAlexander77
ASDAlexander77 deleted the tslang-181 branch November 24, 2026 13:45
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