Repository navigation
-mm=own: a linked list compiles (walk, push, append, pop, unlink); readiness page - #869
Merged
Merged
Conversation
…adiness page A singly linked list whose nodes own their `next` was refused in every method: - A `let` given only borrows owns nothing: what is read through it lasts as long as what the `let` borrowed, so `c = c.next` in a loop no longer ends its own borrow. Its declaration is a kill for an assigned borrow's uses. - A field of the value read, overwritten, frees nothing above it: `c.next = n` and `c.next = null` after a walk, when the `let` only walks down. - `n.next = this.head; this.head = n;` is the move of a field with the source refilled right after (TSLANG 49): rc's retain of the refill's value is let through. - `this.head = this.head.next` and `prev.next = prev.next.next` take the value out of the object the place holds, which the store's release frees. A new op, ts.TakeOutOfField, gives the field up: emptied in a mortal object; an object an append-only global keeps too keeps it, and the value is made immortal. Still refused: the popped node used after the assignment, `this.head = new Node(v, this.head)`, a walk that assigns a parameter, a recursive insert that gives its parameter back. docs/own-readiness.md says where the model stands, with measurements; spec 82. Tests: 00linked_list, 00linked_list_kept (every model, and -noopt under own), seven own_err_list_* cases. ctest 7497/7497 on Windows; the own tests on Linux under MALLOC_PERTURB_ (2217/2217); the corpus, 1,000 fuzz seeds and native_ts_graphics' own build have no file newly refused; the default library's own build passes its tests. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ASDAlexander77
added a commit
that referenced
this pull request
Nov 16, 2026
…ive tree insert and parameter walks compile (#870) * -mm=own: a node made from the old head, a recursive tree insert, a walk that assigns its parameter; a walk cut ahead of itself is refused again Three linked-structure shapes #869 left refused now compile, and a hole #869 opened is closed: - A field given to a call that keeps it, refilled from the call's result (`this.head = new Node(v, this.head)`, `t.left = insert(t.left, v)`): the field is given up before the call (ts.TakeOutOfField) and the refill's release stays. Only for a call that never throws, whose other arguments hold no heap block or are the object `new` made. - `__own_no_throw`: the signature pass marks calls whose callees (and all they call) have no throw. Without it a throwing constructor caught by a caller would empty the list where gc and rc keep it. - A parameter (or a `let` given one) whose every assignment reads out of what it holds (`n = n.next`) borrows the caller's value instead of being kept. - Fixed: `const nx = n.next; n.next = null; n = nx` compiled since #869 and read freed memory at run time. A walking `let` frees nothing above the value read only where it is read after being given that value. Spec 83; the user guide and the readiness page are updated. Tests: 00linked_list_build (every model, and -noopt under own), and own_err_list_unlink_walk, _cut_through_alias, _push_ctor_throws, _push_through_this, own_err_tree_field_given_twice, own_err_param_walk_mixed. ctest 7513/7513 on Windows; own and list tests on Linux under MALLOC_PERTURB_ with tcache off 2233/2233; corpus: no file newly refused (00for_condition_narrowing newly compiles, output as gc's); 500 fuzz seeds (936 programs) no failure; native_ts_graphics' own build unchanged; a 20M iteration churn of the new shapes stays flat in memory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * -mm=own: no field given to async code; a walking parameter swapped stays kept; the in-step cut pinned Review follow-ups to the previous commit: - __own_no_throw also counts ops of the async dialect as throwing (an await rethrows what the awaited body threw). - walksDownOnly accepts only reads, rc's counts and the debugger's record besides its walk-down stores: a swap or a given-away address keeps the parameter kept. - own_err_list_cut_in_step pins the ordering half of the walk-cut fix: `c.next = (c = c.next, null)` crashes at run time on main. own_err_list_cut_through_alias was refused before #869 too. - The user guide and the readiness page say the call must be one of the same module. ctest 7514/7514 on Windows; Linux own and list tests 2234/2234 under MALLOC_PERTURB_ with tcache off; corpus unchanged but the two crash shapes; the default library's own build 219/225 in all four configurations (6 skipped by design). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- 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.
What
Under
-mm=own, a singly linked list whose nodes own theirnextwas refused in every method a newcomer writes first. It compiles now:for (let c = this.head; c; c = c.next)and thewhileform, overthis, a parameter's list or a local list.n.next = this.head; this.head = n.c.next = norc.next = nullafter the walk.this.head = this.head.next,c.next = c.next.next, also throughconst h = this.headwhenhis read before the assignment.It also adds
docs/own-readiness.md: where the model stands, with measurements (corpus coverage, fuzzing, the tier 3 exit criteria, what is left).How
Four rules in the inference pass (design log, section 82):
letgiven only borrows owns nothing (chainOf). What is read through it lasts as long as what theletborrowed, soc = c.nextin a loop no longer ends its own borrow. The declaration is a kill for an assigned borrow's uses.checkPlaceRead). Through alet, only when theletwalks down from there on: every later assignment reads out of what it holds, through owning places.refilledFieldTakeOf): rc's retain of the refill's value is let through.splicedFieldTakeOf). The store's release frees the object, so its field is given up right before it.Rule 4 needs a new op,
ts.TakeOutOfField(object, field). Emptying the field is right when the object is freed. An object an append-only global keeps too is not freed, and emptying its field showed (KEEP[0].nextwas null under own, not under gc). The op empties a mortal object's field; an immortal object keeps it, and the value is made immortal.Still refused
this.head = h.next; return h.v): read it first.this.head = new Node(v, this.head).n = n.next).t.l = ins(t.l, v)).Tests
00linked_list,00linked_list_kept: gc, rc, none and own, JIT and compiled; also-nooptunder own.own_err_list_*expected-error cases: a drop inside the walk, a call that clears the list, a look-ahead alias, aletthat may walk back up, the popped node used after, anextkept twice, a refill from a parameter's node.Verification
MALLOC_PERTURB_letFor the reviewer
mainhangs on it too, so it is not from this change; it is not fixed here.🤖 Generated with Claude Code