XO0416: const value holds a handle
A constant is an immutable value shared by every task, not a global variable. Its type may not contain, at any depth, a Mutex, a channel, a task handle, or another handle type, since that would make it shared mutable state. Create the handle in main or a scope and pass it down. See core 3.1 and decision 0332.
Example
const LOCK = Mutex.new(0)Fix
fn main(os: Os) {
let lock = Mutex.new(0)
lock.with(fn(var n) { n += 1 })
}Run xo explain XO0416 for this text in a terminal, or see
section 10.6 of the specification.