Skip to content

-mm=own: an accessor of another module's @final class keeps its borrows too - #682

Merged
ASDAlexander77 merged 1 commit into
mainfrom
own-final-imported-accessor
Oct 24, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
own-final-imported-accessor

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Problem

#681 made a method call on an object of another module's @final class resolve to the method it names, so the library's __own_no_drops applies. An accessor goes through the vtable by a ts.VirtualSymbolRef instead of a ts.ThisVirtualSymbolRef, and that still resolved to the accessor's family. So reading a getter or assigning a setter ended every borrow it could reach: a record that borrows the object (m.pairWith(a)) could not be read after m.weight or m.weight = 3.

Fix

An accessor the library does not list still ends the record's borrows, and so does one on a class that is not @final.

Tests

  • export_own_record.ts: Maker gains a weight get/set pair, which destroys nothing, and a @keeps("n") set rebase, which replaces the node a record borrows.
  • import_own_record.ts: the record from m.pairWith(a) is read after m.weight = i and m.weight (gc, rc, own; AOT and JIT).
  • import_own_record_final_drops.ts (new negative): a read after m.rebase = ... is refused.
  • Full suites: Windows 5522/5522, Linux 5500/5500.

Spec notes extended: own memory model §15.7, final classes ("Amended 2026-10-24").

🤖 Generated with Claude Code

…ws too

#681 resolved a method call on an object of another module's @Final class as
a call to the method it names, so the library's __own_no_drops applied. An
accessor goes through the vtable by a ts.VirtualSymbolRef instead, which still
resolved to its family, so reading a getter or assigning a setter ended every
borrow it could reach: a record could not be read across `m.weight`. MLIRGen
now marks an accessor's ts.VirtualSymbolRef __final_receiver as it marks a
method's ts.ThisVirtualSymbolRef, and resolveValue reads it the same way.

An accessor the library does not list still drops
(import_own_record_final_drops.ts: a setter that replaces the borrowed node).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 63712f3 into main Oct 24, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the own-final-imported-accessor branch October 24, 2026 00:11
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