var.opIndexAssign

void opIndexAssign(T)(T rhs, string key) @safe

Assign a value to a child by key (map-style assignment).

This ensures the current value is a map (converting from Type.NULL on first use), then assigns rhs to the entry under key.

void opIndexAssign(T)(T rhs, size_t index) @safe

Assign a value to an array element by index.

Without this overload, the compiler commits to the map-style opIndexAssign rewrite and a[0] = value fails to compile for arrays, even though a ref-returning opIndex(size_t) exists.

Preconditions:

  • The current value must be Type.ARRAY (or NULL in coercion mode).
  • index must be in range [0 .. length), otherwise a VarIndexException is thrown.