1 package main
2 3 // Regression test for spawn move-semantics cross-block tracking.
4 // Prior to the fix in compiler/restrict.go, the check only walked the
5 // same basic block for post-spawn uses of moved values, so uses in
6 // reachable successor blocks silently passed validation. The BFS
7 // reachability walk now flags them.
8 9 func echo(x int32) {
10 println(x)
11 }
12 13 func compute() int32 {
14 return 42
15 }
16 17 func main() {
18 x := compute()
19 flag := x > 0
20 if flag {
21 spawn(echo, x)
22 }
23 println(x) // ERROR: variable used after spawn in reachable successor block
24 }
25