OxL Справочник OxL
РусскийEnglish

error global-mutable

error Стандарт: [§4.1]

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#

oxl✓ проверяется в CI
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#

oxl✓ проверяется в CI
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.

See also#

OxL 1.0.0-beta · Версия документации 1.0.0-beta© OxwaldLink · сгенерировано из Стандарта, исходников std и руководства