Repository navigation
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 intoSep 24, 2026
Conversation
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): Note for the seed: the seed-built stage1 of this tree fails Ready to merge: |
ehartford
marked this pull request as ready for review
September 24, 2026 14:48
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
force-pushed
the
fix-1567-d63-owned-closure-env
branch
from
September 24, 2026 14:59
c5e9104 to
0471db3
Compare
Contributor
Author
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.
Fifth layer of the closures stack — the D63 implementation (spec §12.4 "The callable type", decisions.md D63).
move ||closure owns its environment: inline in the pair's context when every capture isCopy, otherwise a heap cell owned by the closure value, freed when the value drops, capturedDropvalues destroyed then — never the caller's frame. It may be returned, stored in a struct/Vec, or handed tospawn_os(Amoveclosure sent to spawn_os keeps its environment in the caller's frame: a captured Drop value is destroyed on the creator thread after join, and one consumed inside the closure is dropped twice (D62, §12.4) #1605).fn(A) -> Ris notCopy, bare functions included:let g = fmoves; calling through a binding or field observes;.clone()is free for bare/non-move closures and requires every captureClonefor move closures; the use-after-move diagnostic names both fix-its.onceannotation is A call through a&fn(A) -> Rparameter runs nothing:read(s)whereread: &fn(&str) -> strprints no output and no diagnostic (seed and origin/main) #1603/Deferred: aonceparameter annotation so a consuming closure can cross a bundle boundary (D63 §12.4 call-once) #1604).&T.extern "C".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-allocda_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.