Skip to content

Closures: a move closure owns its environment; fn(A) -> R is not Copy; consuming closures are call-once (D63, §12.4; #1567, #1605, #1603, #1604) - #1620

Merged
ehartford merged 3 commits into
fix-1567-returned-closure-envfrom
fix-1567-d63-owned-closure-env
Sep 24, 2026
Merged

ehartford merged 3 commits into
fix-1567-returned-closure-envfrom
fix-1567-d63-owned-closure-env

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Fifth layer of the closures stack — the D63 implementation (spec §12.4 "The callable type", decisions.md D63).

Fixtures: behav_closure_returned_move_env, behav_callable_clone_and_call_through, behav_closure_consuming_arg_invoked_once; err_callable_moved_then_used, err_closure_consuming_arg_invoked_twice, _in_loop, err_closure_view_arg_to_storing_callee, err_closure_returned_copy_capture (updated); debug-alloc da_closure_move_env_owned, _consume_once, _spawn_os. Non-Copy flip sites: lib/std/collections/hash_index.w, rt/rt_core.w, src/compiler/ConanPatch.w, three behavior fixtures.

Stack rebased onto main 2c7ed44 (one cell-list conflict in tools/drop_audit.w, both sides kept). The stack's seed-driven battery with audits is the verdict.

@ehartford
ehartford added this pull request to stack #1585 September 24, 2026 13:50
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery green — closures stack #1585 (main → #1583 → #1584 → #1591 → #1592 → #1620), top c5e9104 on main 2c7ed44, pinned seed, cold c_import cache, audits included (drop scheduling):

build        rc=0
:fixpoint    rc=0
:drop-audit  rc=0
:move-audit  rc=0
:test        rc=0   (no red targets; stdlib-complexity green with the §3.8 harness spelling and the &fn marshalling fix)
:test-green  rc=0
:last-green  rc=0

Note for the seed: the seed-built stage1 of this tree fails build/run of test/complexity/stdlib.w with "internal error: conflicting contextual join decisions for one expression" (SemaCheck.w:832, at <embedded-std>/std/collections/sorted_vec.w:72) while check passes and the stage2-built compiler is clean (this battery). A stage1-only divergence under the current seed — cut a new seed after this lands (tools/bump_seed_pins.w, :seed) so :dev iteration is trustworthy again.

Ready to merge: gh stack merge 1620 --squash.

@ehartford
ehartford marked this pull request as ready for review September 24, 2026 14:48
Eric Hartford added 3 commits September 24, 2026 10:59
…ure is Copy, else a heap cell freed on drop) and may be returned, stored or spawned; fn(A) -> R is not Copy — calls observe, .clone() duplicates, use-after-move names both fix-its; a consuming closure is call-once at the call and across a signature (D63, §12.4 "The callable type"; #1567, #1605, #1603, #1604)
…hey take &fn(i32) -> i32 (§3.8) — fn(A) -> R is not Copy under D63 and the plain parameter consumed it
…shalled as the address of its fat pair, not as its code pointer — the callee read a pair out of instruction bytes and jumped into them (pre-existing on main; the D63 §3.8 spelling of the complexity harness exposed it)
@ehartford
ehartford force-pushed the fix-1567-d63-owned-closure-env branch from c5e9104 to 0471db3 Compare September 24, 2026 14:59
@ehartford

Copy link
Copy Markdown
Contributor Author

Rebased onto main c18fdfe (stages 10/12/13 landed under the stack): patch-id identical (0d7bcf75), so the green battery stands. Top is now 0471db3. Ready: gh stack merge 1620 --squash.

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