Skip to content

[diagnostic] the HYB-E3004 fix-it recommends fresh := m; move fresh, which the checker then rejects with the same error #2272

Open

Description

@slabhousextracts-blip

Summary

The HYB-E3004 fix-it tells the user to do something the checker then rejects. Following the recommended remedy verbatim produces the same error again, so the diagnostic loops.

Not a soundness hole — a diagnostic-accuracy bug. The fix-it is the teaching surface (Q1 item 3), and this one teaches a dead end.

The fix-it, verbatim

From compiler/crates/hy-check/src/freeze.rs:535 on main @ 1f0ff97:

fix: copy m into a fresh local before moving (fresh := ...; move fresh), move the caller's owned binding at the spawn/send site directly, or wrap a genuinely synchronized share in managed("reason", "category") { ... }`

Following it verbatim

// fixit_dead_end.hy
fn worker(m map[string]int) {
    m["x"] = 1
}

fn spawner(m map[string]int) {
    fresh := m                 // exactly what the fix-it says
    task worker(move fresh)    // exactly what the fix-it says
}

fn main() {
    shared := map[string]int{}
    spawner(shared)
    shared["y"] = 2
}
$ hyb check fixit_dead_end.hy
error[HYB-E3004]: cannot move `fresh` (map[string]int) — `move` requires an exclusively owned local binding, not parameter `m` (the caller retains the argument across intra-task calls) (O5.1 / O5.4)
  --> fixit_dead_end.hy:6:17
  = why: parameter `m` (the caller retains the argument across intra-task calls) still aliases the underlying storage outside this move site, so freezing `fresh` cannot prevent concurrent access (O5.2 / O5.4)

The same fix-it text is emitted, so the user is told to run the exact command that just failed. Structs behave identically (fresh := v where v is a parameter → not a may-share peer of parameter \v``).

Why the advice is wrong

fresh := m copies the binding, not the storage. For a map the header is copied but the backing table is shared, so the caller still aliases it — which is precisely what the = why: line says. The advice and the explanation contradict each other in the same diagnostic.

What would actually work (and is accepted)

A real copy of the storage, or moving the caller's binding at the call site:

// accepted today
fn spawner(m map[string]int) {
    fresh := map[string]int{}
    for k, v in m { fresh[k] = v }
    task worker(move fresh)
}
// also accepted: move at the caller's own binding
fn main() {
    shared := map[string]int{}
    task worker(move shared)
}

Expected fix

Either (a) reword the fix-it to say the copy must be a deep copy (and show one), or (b) make fresh := m genuinely fresh for reference types so the advice becomes true. (a) is smaller and honest; (b) changes copy semantics.

Environment

main at 1f0ff97, hyb built from source (HYB_PINNED_RUST=1.97.1, local rustc 1.97.1), go1.26.9. Reproduced 2026-10-29. Fix-it text confirmed present on main after #410 merged (2026-10-17).

Activity

  1. jpereyra243-byte commented on Oct 30, 2026

    @jpereyra243-byte
    Contributor

    /claim #2272

    Working on diagnostic wording fix in compiler/crates/hy-check/src/freeze.rs to clarify deep copy requirement and prevent self-contradictory fix-it loops.

    Settlement wallet (Polygon USDC):
    0xC175c34c256598C7e1AD5B15503cFcED7Ed67e10

  2. added a commit that references this issue on Oct 30, 2026
    d91a272
  3. added a commit that references this issue on Nov 14, 2026
    6352f89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions