collections: element steps and --explain-copies through the ArrayList record (follow-up of #526) #565

Open
opened 2026-10-29 06:35:30 +00:00 by orion · 2 comments
Collaborator

Context

Follow-up of #526 (PR #529, step 3 of #55). Since ArrayList is a TorbScript record over Buffer<Item> (items, start, count, COLLECTION-STORAGE.md decision 1), two passes no longer see the list through that record:

  • ir/elements.trb: isListSetter accepts a set that forwards to items.set index, value (the wrapper shape of #468), but ArrayList.set rebases a windowed or shared list first and writes at start + index. So a[i].f = v on an ArrayList takes the round trip (read the item, write the field, set it back) instead of one PathStep.Element.
  • --explain-copies (torb build --explain-copies) reports no copy for a nested write into an ArrayList row another value still holds.

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) and tests/command-line/copies to the harness/std TrieList, which is still the runtime's list, so they keep testing the passes. The harness prelude (compiler/tests/harness.trb) still declares native type ArrayList without manifest rows; only the debugger tests and lower-collections use the std shape (windowedList, declaredListFiles).

Goal

A write through an element of an ArrayList is one element step again, --explain-copies names its copy, and the tests run over the ArrayList of the std shape.

Acceptance criteria

  • ir/elements.trb sees through the set of the ArrayList record (the rebase, then the storage's set at start + index): a[i].f = v, grid[i][j] = v, a method and a closure on an element are element steps on an ArrayList, as elements.test.trb pins for the runtime's list.
  • --explain-copies reports the copy of a nested write into a shared ArrayList row (explain-copies.test.trb, tests/command-line/copies over ArrayList again).
  • The harness prelude declares ArrayList in the std shape (no native type ArrayList), and the tests moved to TrieList in #529 go back to ArrayList where they are about it.
  • Gates green in both tiers (CI).

Dependencies

#526 / PR #529 (lands first). Epic #55.

## Context Follow-up of #526 (PR #529, step 3 of #55). Since `ArrayList` is a TorbScript record over `Buffer<Item>` (`items`, `start`, `count`, COLLECTION-STORAGE.md decision 1), two passes no longer see the list through that record: - `ir/elements.trb`: `isListSetter` accepts a `set` that forwards to `items.set index, value` (the wrapper shape of #468), but `ArrayList.set` rebases a windowed or shared list first and writes at `start + index`. So `a[i].f = v` on an `ArrayList` takes the round trip (read the item, write the field, `set` it back) instead of one `PathStep.Element`. - `--explain-copies` (`torb build --explain-copies`) reports no copy for a nested write into an `ArrayList` row another value still holds. 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`) and `tests/command-line/copies` to the harness/std `TrieList`, which is still the runtime's list, so they keep testing the passes. The harness prelude (`compiler/tests/harness.trb`) still declares `native type ArrayList` without manifest rows; only the debugger tests and `lower-collections` use the std shape (`windowedList`, `declaredListFiles`). ## Goal A write through an element of an `ArrayList` is one element step again, `--explain-copies` names its copy, and the tests run over the `ArrayList` of the std shape. ## Acceptance criteria - [ ] `ir/elements.trb` sees through the `set` of the `ArrayList` record (the rebase, then the storage's `set` at `start + index`): `a[i].f = v`, `grid[i][j] = v`, a method and a closure on an element are element steps on an `ArrayList`, as `elements.test.trb` pins for the runtime's list. - [ ] `--explain-copies` reports the copy of a nested write into a shared `ArrayList` row (`explain-copies.test.trb`, `tests/command-line/copies` over `ArrayList` again). - [ ] The harness prelude declares `ArrayList` in the std shape (no `native type ArrayList`), and the tests moved to `TrieList` in #529 go back to `ArrayList` where they are about it. - [ ] Gates green in both tiers (CI). ## Dependencies #526 / PR #529 (lands first). Epic #55.
Author
Collaborator

[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: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.
Author
Collaborator

[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

[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
Sign in to join this conversation.
No labels
loop
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#565
No description provided.