error global-mutable
static должен быть frozen или sync.
What it means#
A static is initialised once, on its first access, thread-safely, and its type MUST be frozen or sync. There are no mutable globals without sync (§4.1, §3.7). Accepted types (D-3481): frozen T / sync T, immutable (Copy) values, Broadcast<T>, Arc<S> of an accepted S, and tuples, arrays and unions (T?) of accepted types. A static cannot be assigned to (not-assignable).
Example#
static TABLE: List<i32> = [1, 2, 3] // <- global-mutable
static CACHE: List<i32>? = none // <- global-mutable (the option holds a mutable list)error
global-mutable
How to fix#
static TABLE: frozen List<i32> = [1, 2, 3]Make the value deeply immutable with frozen, or use a sync type such as Broadcast<T> (or Mutex<T> / TVar<T> once available) for state that changes.