collections: element steps and --explain-copies through the ArrayList record (follow-up of #526) #565
Labels
No labels
loop
queue/failed
queue/queued
ready
status/parked
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
torbscript/language#565
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Follow-up of #526 (PR #529, step 3 of #55). Since
ArrayListis a TorbScript record overBuffer<Item>(items,start,count, COLLECTION-STORAGE.md decision 1), two passes no longer see the list through that record:ir/elements.trb:isListSetteraccepts asetthat forwards toitems.set index, value(the wrapper shape of #468), butArrayList.setrebases a windowed or shared list first (own()) and then writesitems.set index, value.fieldForwardedCalleedemands exactly one instruction, the stdsethas two, so it does not match; andelementTypeOfaccepts only aRuntime(ListStorage, [Item])container with a list setter. Soa[i].f = von anArrayListtakes the round trip (read the item, write the field,setit back) instead of onePathStep.Element.--explain-copies(torb build --explain-copies) reports no copy for a nested write into anArrayListrow another value still holds:tokenOf/factOfgive anatcall an alias without theField(items)token,listHoldingElement/isListTyperecognise onlyRuntime ListStorage, andnounOfnames the record ("record", "O(number of its fields)") instead of the list.PR #529 moved the compiler tests that pin these shapes (
elements.test.trb,explain-copies.test.trb,lower-natives.test.trb,lower-places.test.trb,crossing.test.trb,partial.test.trb) andtests/command-line/copiesto the harness/stdTrieList, which is still the runtime's list, so they keep testing the passes. The harness prelude (compiler/tests/harness.trb) still declaresnative type ArrayListwithout manifest rows; only the debugger tests andlower-collectionsuse the std shape (windowedList,declaredListFiles).Goal
A write through an element of an
ArrayListis one element step again,--explain-copiesnames its copy, and the tests about these two passes run over theArrayListof the std shape. Switching the whole harness prelude is split out (#837).Requirements
setof the stdArrayListshape (a call of a private self-onlyvar fnthat rebases the list,own(), followed by the storage setter on theitemsfield with the arguments forwarded),isListSettershall accept it, recognised by that shape, not by name.ir/elements.trbrewrites the round trip of anArrayListelement, it shall emit the sameown()call before the write, then oneReference(container.base, steps + Field(items) + Element(item, key, at)), so the observable behaviour (rebase of a windowed or shared list, panic on a bad index) is unchanged.elementTypeOfshall accept the recordArrayList<Item>besidesRuntime(ListStorage, [Item])andFixedArray, givingItem; a look-alike that is not the std shape (other fields, two writes, a different callee) shall stay a round trip.readerSiteOfshall keep requiring exactly one panic in the reader; the stdArrayList.athas one, so no change is expected there, and a test pins it.--explain-copiesfollows anArrayListelement, its alias path shall carry theField(items)token,listHoldingElement/isListTypeshall recognise theArrayListrecord, and the copy shall be named as a "list",O(length of the list), with the way-out hint of today. A copy reported at several MakeUnique levels (the record and its buffer) shall appear once.TrieList(runtime list) as today: its tests stay green unchanged.Files
compiler/src/ir/elements.trb:isListSetter,fieldForwardedCallee(or a sibling for the two-instruction shape),putBackArguments,elementWriteAt,elementTypeOf,rewritten,ownersMadeUnique.compiler/src/ir/explain-copies.trb:tokenOf/placeAlias,factOf,listHoldingElement/isListType,nounOf,reasonOfCopy.compiler/src/ir/lower/place.trbonly ifelementWritersneeds the record'ssetregistered (check; theatreaders are already registered).compiler/tests/elements.test.trb,compiler/tests/explain-copies.test.trb: the tests below, over the stdArrayList.compiler/tests/harness.trb: a helper that gives a test the stdArrayList(reusedeclaredListFiles, make it carryown()as instd/collections/src/list.trb); no change of the global prelude.tests/command-line/copies/src/main.trband its expected output: back toArrayList.docs/design/COLLECTION-STORAGE.md: the status line ("its element steps and its allocations are open (#565, #566)") says only #566 is open.Tests
elements.test.trb, over the stdArrayList: field of an element, nested index writegrid[0][1] = 5, a method on an element, a closure on an element are one element step; a container that two implementations meet in (ArrayList + TrieList) stays a round trip as today; look-alike setters (two writes, other callee, other field) stay a round trip.explain-copies.test.trb:held = rows[row]then a nested write reports the copy of the list ("heldstill holds the list ... (O(length of the list))" with the way-out hint), once, overArrayList.tests/command-line/copies: output overArrayListas it was before #529.TrieListvariants stay for the runtime list.Acceptance criteria
ir/elements.trbsees through thesetof theArrayListrecord (the rebase, then the storage'sset):a[i].f = v,grid[i][j] = v, a method and a closure on an element are element steps on anArrayList, aselements.test.trbpins for the runtime's list; look-alike setters stay a round trip.--explain-copiesreports the copy of a nested write into a sharedArrayListrow, once, as a list copy (explain-copies.test.trb,tests/command-line/copiesoverArrayListagain).ArrayList;TrieListtests are unchanged and green.Seed
Compiler-only change with existing syntax: recognition by shape in
ir/elements.trbandir/explain-copies.trb, no new syntax, no native, no name the compiler looks up in std. The seed question is therefore no: one commit, the two-commit rule does not apply,seed/stays untouched.Size
One PR (a few hours): two compiler files, two test files, a harness helper, one command-line test, one doc line. The global prelude switch is out (#837).
Dependencies
#526 / PR #529 (merged). Epic #55. #837 follows this issue; #566 is independent.
Decided by the loop
ArrayList, so a user type of the same shape benefits and a look-alike does not.own()call and adds theField(items)step; it does not drop the rebase (behaviour of windowed and shared lists stays).--explain-copiesnames the copy as a list copy (O(length of the list)), the user-facing noun; the record's own fields are not shown.native type ArrayListto the std shape is out of this issue: it touches many test files, snapshots and counts and cannot be iterated locally (CI only). Filed as #837.[loop:orion] labelled
loop: live-design follow-up of #526 / PR #529 (epic #55), filed by an interactive session without the label. Not superseded; no retirement.[loop:torbscript] intake: in scope (author orion, label loop), no duplicate, no collision with a design record; dependency #526 / PR #529 is merged. Compiler pass work (ir/elements, --explain-copies), no owner question, no seed change known (to be confirmed in refine). next: refine
ArrayList, the hash tables and the tries onBuffer#55ArrayList, the hash tables and the tries onBuffer#55ArrayList, the hash tables and the tries onBuffer#55[loop:torbscript] refine: next: waiting (the ready buffer is full, 12 issues are ready against a refine threshold of 4, and 8 pull requests are open against a cap of 8; refine resumes when ready items have been picked up)
[loop:torbscript] claim refine by session:loop-torbscript-565-refine until 2026-11-16T14:38:00Z
Reason: focus item #55 (epic), step 3a. Ready buffer is 3 of 4 (#836, #620, #365), one worker slot free.
ArrayList, the hash tables and the tries onBuffer#55[loop:torbscript] decided by the loop: #565 is scoped to the two passes (
ir/elements.trb,ir/explain-copies.trb) plus the tests about them; the stdArrayList.setis recognised by shape (own()then the storage setter onitems), the rewrite keepsown()and addsField(items); copies are named as list copies. The global harness prelude switch (many test files, snapshots, counts, CI-only iteration) is split out as #837. Seed: compiler-only, existing syntax, one commit, two-commit rule does not apply. Numbers: ~6 files (2 src, 2 tests, 1 harness helper, 1 command-line test) plus one doc line. Details in the issue body ("Decided by the loop").[loop:torbscript] refine: ready. Body rewritten to the writing standard (context, R1-R6, files, tests, acceptance criteria, seed statement, size, dependencies, decisions); label
readyadded; the harness prelude switch split out as #837 (labelloop, depends on this); claim released. next: implement[loop:torbscript] claim implement by session:loop-torbscript-565-implement until 2026-11-16T18:50:00Z
Reason: #565 is ready (newest refine release), ready buffer is 4 of 4, openPrs 2 of 8, one worker slot free.
[loop:torbscript] implement: PR #838 (head
loop/565-arraylist-element-steps, one commit5de6207c, Argus requested). next: waiting (forge CI of5de6207chad not started after 30 min, all four checksWaiting to run; the next tick readsci-wait.shagain and fixes a red run on the same branch)What changed:
ir/elements.trb: recognizes theArrayListwindow record by its layout (windowLayoutOf, now public), rebases once with the setter'sown()and writes the element in place as onePathStep.Elementchain (take-out and put-back dropped).ir/explain-copies.trb: the window record counts as the list (noun, held-row, method-on-row and live-alias notes); the rebase call forgets only the storage facts.tests/command-line/copiesis anArrayListagain; the pinned report text and position are unchanged.docs/design/COLLECTION-STORAGE.mdstatus: only #566 is open.elements.test.trb21 passed,explain-copies.test.trb15 passed,lower-collections.test.trb14 passed,counted.test.trb3 passed,torb format --checkclean,check-commits.shclean,skills/unchanged bydocs skill. Gates, bootstrap and thecopiescommand-line case are CI-only and not yet seen.ArrayList, the hash tables and the tries onBuffer#55std/livepage placement (WEB slice 6) and the client script (slice 7) #103?in a body whose result type is inferred #747[loop:torbscript] done: merged as PR #838 (argus, 2026-11-16 16:02 UTC, merge commit
426b9fcf). Acceptance: ArrayList window layout recognized in ir/elements.trb and ir/explain-copies.trb, tests/command-line/copies is an ArrayList again with the same pinned report text. Merge-commit CI was still pending at 17:02 Berlin; main carries the change, so it ships in the nightly of 2026-11-17 (automatic, no tag needed). Next step (not done here): the change belongs to the stable 0.1.0 cut on the first Tuesday, 2026-12-01 (docs/contributing/releasing.md), not an out-of-cycle tag. Stale label ready removed.[loop:torbscript] claim fix by session:loop-torbscript-main-fix until 2026-11-16T20:10:00Z Reason: main CI is red at
426b9fcf(merge of PR #838, this issue): jobstier A (linux-x64)andgatesfailed in run 3182. Red main comes first; the worker diagnoses from the run logs and opens a fix PR or a revert PR (no merge, no push to main).[loop:torbscript] main-fix: red main at
426b9fcfis not caused by this issue. Tier A fails instd/json-schema/tests/suite.test.trb: 17 idn-hostname known-difference entries became stale when the std/dns commitsfbca4f09and11fe42c9landed (red since11fe42c9). Fix PR: #840 (Argus requested), next: waiting (merge gate, then main CI green).[loop:torbscript] release by session:loop-torbscript-main-fix: fix PR #840 is open (branch
loop/main-fix-idn-hostname, one commit, Argus requested). The loop never merges; main CI is re-read after the merge gate lands it.