You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[soundness] Self-shadowing define (m := m) in an inner block drops the parameter/receiver non_owned_origin: move m accepted, data race #141
hyb built from main @ f99d6d0 (pinned go1.26.9 / rust 1.99.0).
package main
fn worker(m map[string]int, done chan bool) {
for i in0..1000 {
m["k"] = i
}
done <- true
}
fn spawn(m map[string]int, done chan bool) {
if true {
m := m
task worker(move m, done)
}
}
fn main() {
m := map[string]int{"k": 0}
done := make(chan bool, 1)
spawn(m, done)
for i in0..1000 {
m["k"] = i
}
<-done
}
$ hyb check param.hy
$ hyb build param.hy -o out/param --emit-go && go vet out/param.go # clean
$ go run -race out/param.go
What the checker should say
error[HYB-E3004]: cannot move m(map[string]int) — move requires an exclusively owned local binding, not parameterm`` (tier0_rule A1b), the same diagnostic main already gives for task worker(move m, done) directly and for `m2 := m; task worker(move m2, done)`. The inner `m` aliases the caller-owned parameter, so moving it into a task races with the caller's writes.
What it actually said
param.hy: OK (0 diagnostics)
and go run -race reports WARNING: DATA RACE (exit status 66).
Claimed severity
P0 — data race reachable in the checked subset
Anything else
Self-shadowing define (m := m, h := h, s := s, m := same(m)) in an inner block drops the shadowed binding's non_owned_origin (O5.1 guard from #61), because process_local defines the new binding before record_alias / record_may_share resolve the RHS ident, so they see the new inner binding. Same hole with a method receiver and a struct parameter. Fix with regression tests: #140.
Activity
Merge pr-140 (salvocanci, fixes limitlessprojects#141): a self-shadow…