Skip to content

D115 Amendment 1 step 2: the List header's word 3 is start, an owned List's head comes off in O(1); #2289 guards after a take - #2352

Merged
ehartford merged 4 commits into
mainfrom
d115-step2
Oct 12, 2026
Merged

ehartford merged 4 commits into
mainfrom
d115-step2

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Two commits on top of the seed bump (7a3737b66), building from nightly-20261011-local-2, which has the sized helpers step 1 introduced.

  • Step 2 (cafb4ba72): word 3 of the List header is start, the elements before ptr in the allocation. [h, ..t] over an owned List takes the head by advancing the header (LIST_TAKE_FRONT → with_vec_take_front_es), so the canonical recursion is O(n) and allocation-free per step; grow and free read the allocation through start; shrink_to_fit() releases the prefix and the spare capacity; the stack literal (D119) writes 0 at word 3; the unsuffixed helpers, the C header's old prototypes and the last compiler-internal raw uses go. Fixture: behav_d115_amendment1_offset_rest.w.
  • D115: a match guard after an owned-Vec slice pattern that removes elements is refused #2289 (8bb082554): a match guard may follow a pattern that takes elements out of an owned List: a failed guard puts a head back through the prefix (LIST_RESTORE_FRONT) and a tail back by push, after the move log has put the remainder back in the subject. Fixture: behav_2289_guard_after_owned_list_take.w, leak-free under the debug allocator.

Found and filed: #2351 (match move on a List parameter whose pattern takes nothing out, or leaves the remainder under a bare .., leaks the subject) — pre-existing, reproduced on the installed compiler; the allocation-count fixture for Amendment 1 waits on it.

Gate and battery: pending.

Eric Hartford added 4 commits October 11, 2026 21:42
…ed List's head comes off in O(1) (LIST_TAKE_FRONT advances ptr/start), grow and free read the allocation through start, shrink_to_fit releases the prefix; the unsuffixed helpers go; both backends and the C header follow
…es elements out of an owned List; a failed guard puts a head back through the prefix (LIST_RESTORE_FRONT) and a tail back by push, after the remainder is back in the subject
…e base; two ceremony items the gate caught
…ired; behav_2289_guard_after_owned_list_take covers the accepted form
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery green on bc5eac7 (seed-driven, with run tools/battery.w in the staging worktree under nightly-20261011-local-2; battery 1 was red only on the retired compile-error fixture that pinned the #2289 refusal). Gate 1 was red on one root cause, the drop-origin free computing the base before testing the pointer, fixed in 04ef213.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant