Repository navigation
-mm=own: a borrow ends only where what it reads is overwritten or freed (TSLANG 236-240) - #1129
Merged
Merged
Conversation
…ed (TSLANG 236-240) - 236: a call's result that borrows one argument records the places it is read through (__own_result_places), so a call that overwrites an unrelated field no longer ends the borrow. - 237: emptying an int[] ends no borrow (its elements hold no object), and `xs.length = 0` through `const xs = this.xs` is accepted like `xs.pop()`. - 238: a closure that does not escape borrows what a named const owns, as it borrows a parameter; it no longer moves the const. - 239: a call's result borrows only the arguments its facts name, so `t.copy(pts[0])` no longer stores `pts`. - 240: a value given to the call that may free it takes a reference of its own across the call (USER RULING 11-27, TSLANG 219), whatever form the argument has. Also: a lent-back result (`this`) of a counted named const is not released, which freed the receiver one release early. Tests: 00tslang_issue_236..240 (gc, rc, none, own; AOT and JIT, with churn); six new own_err_* refusals keep the overwrites that do end a borrow; seven own_err_* cases now counted become own_counted_* (output = rc); own_err_callback_cast_field_drops is refused at its caller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # tslang/test/tester/CMakeLists.txt
…lent `this` reaches its object (TSLANG 240) Found with a new memory-model fuzzer mode, mm_fuzz.py --classes (class K whose methods lend fields back, return `this`, replace or empty fields, free them and read their argument, and run stored callbacks). - A call's result lent back as `this` (`k.self()`, `k.add2(..)` returning `this`) was taken for an object apart from `k`: `k.self().add2(k.first())` passed the check while `add2` freed `k.arr` under the borrow, and crashed (pre-existing on main). The owned-root test in dropsChain now follows a lent call result to the arguments it borrows, and argumentOwnsApart never calls one apart. - USER RULING 12-04: a value given straight to the call that may free it is counted across the call whatever form it has: a call's lent result (`k.add2(k.first())`) or a field or element read (`k.run2(k.arr[0])`), not only a named local. A lent temporary takes a count; rc's release of it gives it back. Tests: 00tslang_issue_240_temps (gc, rc, none, own; AOT and JIT). Eight own_err_* cases now counted become own_counted_* (output = rc). own-facts-objects and own-shared-no-drops check the count without facts instead of a refusal. 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.
Fixes TSLANG 236-240: under
-mm=own, borrows were ended or refused where nothing they read could be overwritten or freed.__own_result_places, e.g.this.lists[0]). Only an overwrite of those places ends the borrow;this.bag = orderno longer does.int[](length = 0,splice,pop) ends no borrow, because its elements hold no object.xs.length = 0throughconst xs = this.xsis accepted, asxs.pop()already was.constowns, the same way it borrows a parameter. An escaping closure still moves the const, and a later use is still an error.t.copy(pts[0])(returningthis) no longer counts as storingpts.B.add(PAINT.a); B.add(PAINT.a)form releasedBonce too often, because the lent-backthisresult was released.Tests
00tslang_issue_236..240run under gc, rc, none and own, AOT and JIT, with churn allocations between the steps.own_err_*refusals cover the overwrites that do end a borrow:own_err_*cases are now counted under the 240/238 rules. They becomeown_counted_*with rc's output.own_err_callback_cast_field_dropsis still refused, now at its caller.Found by the new fuzzer mode (
mm_fuzz.py --classes, second commit)--classesadds the shapes behind 236–240: methods that lend fields back, returnthis, replace or empty fields, free them and then read their argument, and stored callbacks.this(k.self(), ork.add2(..)returningthis) was treated as an object separate fromk. Sok.self().add2(k.first())passed the check whileadd2freedk.arrunder the borrow. On the same 200 fuzz seeds, main's compiler crashes on 3 programs and this branch on none.k.add2(k.first())) or a field or element read (k.run2(k.arr[0])).own_err_*cases are now counted; they becomeown_counted_*and expect rc's output.own-facts-objects,own-shared-no-drops) now check for a count without facts instead of a refusal.00tslang_issue_240_temps. A 1000-program--classescampaign found no wrong output, and all 3625 own-related ctest cases pass.🤖 Generated with Claude Code