Repository navigation
A const interface or bound method made over a local holds what it shows - #637
Merged
Merged
Conversation
`const i: I = v` and `const m = v.get` were folded: a view of a read of `v`'s slot with no reference of its own, so `v = mkv(2)` freed the object `i` and `m` still used (rc and own). Like a const read straight out of a local's slot (#454), such a const now gets storage like a `let`. An interface is then counted under rc and owned under own. A bound method is still not counted under rc (its `this` carries a null tag), so `const m = v.get` stays broken there, as `let m = v.get` is; under own it is now rejected, as the `let` is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # tslang/lib/TypeScript/MLIRGenImpl.h
ASDAlexander77
added a commit
that referenced
this pull request
Oct 22, 2026
…count (#642) `const m = h.v.get` and `const i: I = h.v` were folded into the view itself, holding no reference of their own, so `h.v = d` freed the object `m()` and `i.get()` then ran on (a crash under rc; `let m = h.v.get` was fine). #637 gave such a const storage when its object is read out of a local's slot, and #640 made a kept bound method count its object; a view over a field read was left out. Under rc it now gets storage like a `let`, as a const read out of a field already does (#635). Under own the folded read stays a borrow. 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.
let v = mkv(1); const i: I = v; v = mkv(2); i.w.xread freed memory under rc and own, and so didconst m = v.get; v = mkv(2); m(). Aconstof an interface view, or of a bound method, made over a read of a local's slot was folded. It was a view with no reference of its own, so the assignment freed the object it still showed. Theletforms were already right for the interface.Fix:
processConstRef(MLIRGenImpl.h) gives such a const storage like alet, as #454 did for a const read straight out of a local's slot. The newviewsLocalSlotlooks throughNewInterface,ThisSymbolRef,ThisVirtualSymbolRefandCreateBoundFunctionto a read of an owning local.Effect per model
let m = v.get. Before, it was accepted and printed 1002 instead of 3.thiscarries a null tag (MLIRTypeHelperownsHeapMemory). Soconst m = v.getis now exactly as broken aslet m = v.getalready was. Counting bound methods under rc is a separate change to the lowering.Tests
tests/00const_interface_of_local.ts: default, rc/none corpus, and own (JIT + AOT).own_err_const_bound_method_reassigned.Results
ctest -C Release, 4865/4865 passed🤖 Generated with Claude Code