Repository navigation
fix(hy-check): reject boundary move of non-owned parameter, closure capture, and non-channel range bindings (HYB-E3004) - #61
Merged
limitlessprojects merged 1 commit intoOct 14, 2026
Conversation
…apture, and non-channel range bindings (HYB-E3004)
ocakciomursel-pixel
force-pushed
the
fix/non-owned-param-and-range-move
branch
from
October 14, 2026 18:51
4e382c6 to
0222e97
Compare
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.
Fixes #60
Participation in #5
Problem
Under
SPEC-LANGUAGE.md§9.3 O5 (O5.1/O5.2/O5.4, ruleA1b),move xat a concurrency boundary (taskspawn or channel send) transfers exclusive ownership ofxso that freezingxand its local aliases prevents any concurrent access in the sending task.Previously, three classes of non-exclusively-owned bindings in
FnStatewere treated as if they were fresh, uniquely-owned local bindings and passedmove xattask/sendsites with0 diagnostics(OK):fn spawn_it(m map[string]int) { task worker(move m, done) }): Intra-task calls do not freeze the caller's argument, so moving a parameter inside the callee leaves the caller's map unfrozen.f := fn() { task worker(move m, done) }; f()):closures.rsclonesst.envinto a temporarycst.env, so moving a captured outer binding inside a closure never freezes the binding in the enclosing function (and the closure can be invoked multiple times).for k, v in mm { task worker(move v, done) }): Iterating a map/slice/array reads elements out ofmmwhilemmcontinues to hold and alias the elements (unlikefor b in chover a channel, which transfers ownership per received element).Fix
compiler/crates/hy-check/src/model.rs:non_owned_origin: Option<String>toBindingto track when a binding originates from a function/closure parameter, method receiver, closure capture, or non-channelfor ... inelement.compiler/crates/hy-check/src/lib.rs&closures.rs:non_owned_originon function receivers, function/closure parameters, outer bindings captured incheck_closure, andForKind::Iteratevariables when iterating a non-channel collection (!matches!(ck.shape_of_expr(..., expr), TypeShape::Chan(_))), while also recordingst.aliasesto the collection root so post-move access to the collection triggersHYB-E3003.compiler/crates/hy-check/src/loans.rs:non_owned_originthroughx := y,x := move y, andx = yrebinds; clear it when a binding is rebound to a fresh value.compiler/crates/hy-check/src/freeze.rs&sendability.rs:Checker::check_non_owned_moveand invoke it atcheck_siteon un-managedmoveoperands so moving a non-exclusively-owned reference-carrying binding across a concurrency boundary rejects withHYB-E3004(tier0_rule: "A1b").compiler/crates/hy-check/src/lib.rs(tests):non_owned_param_capture_and_range_moves_reject_e3004covering parameter moves, closure-capture moves, non-channel range-element moves, and the positive control (for b in in_ch { out_ch <- move b }).Verification
cargo test --workspace: all 256 tests pass (0failures).cargo clippy --workspace --all-targets -- -D warnings:0warnings.python3 tools/corpus_harness.py:25/25verdict agreement, tripwire not fired.Prepared with AI assistance.