Repository navigation
-mm=own: an accessor of another module's @final class keeps its borrows too - #682
Merged
Merged
Conversation
…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>
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.
Problem
#681 made a method call on an object of another module's
@finalclass resolve to the method it names, so the library's__own_no_dropsapplies. An accessor goes through the vtable by ats.VirtualSymbolRefinstead of ats.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 afterm.weightorm.weight = 3.Fix
ClassAccessorAccess): an accessor'sts.VirtualSymbolRefon a@finalreceiver is marked__final_receiver, the same way -mm=own: a method call on another module's @final class keeps its borrows #681 marks a method'sts.ThisVirtualSymbolRef.resolveValuereads the mark on ats.VirtualSymbolRefthe same way: the call is to the function named, soaddImportedapplies.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:Makergains aweightget/set pair, which destroys nothing, and a@keeps("n") set rebase, which replaces the node a record borrows.import_own_record.ts: the record fromm.pairWith(a)is read afterm.weight = iandm.weight(gc, rc, own; AOT and JIT).import_own_record_final_drops.ts(new negative): a read afterm.rebase = ...is refused.Spec notes extended: own memory model §15.7, final classes ("Amended 2026-10-24").
🤖 Generated with Claude Code