Sakura Lang

V0013 invalid_assign_target

The left side of = must be a var name or a field path on one (u.email = e).

An error from the parse phase. sakura explain V0013 prints this explanation offline.

The left side of = must be a var name or a field path on one (u.email = e).

Wrong program

compiler/tests/ui/V0013_invalid_assign_target.sakura, which the compiler's ui suite runs through sakura check:

fn first_to_zero() -> List<Int> {
  var xs = [1, 2]
  xs[0] = Some(0)
  xs
}

sakura check --json reports this record (pretty-printed; $DIR is the fixture's directory):

{
  "schema_version": "1.0",
  "kind": "diagnostic",
  "id": "d:ef783030eb1be953",
  "code": "V0013",
  "severity": "error",
  "phase": "parse",
  "message": "only a variable or a field path can be assigned",
  "snapshot": "sha256:$SNAPSHOT",
  "symbol_id": "main::V0013_invalid_assign_target::first_to_zero",
  "spans": [
    {
      "uri": "file://$DIR/V0013_invalid_assign_target.sakura",
      "content_hash": "sha256:9efe4470093197fa02711feae337771ddb8627e42f4dd694d1f2e2392af074f8",
      "start_byte": 88,
      "end_byte": 93,
      "role": "primary"
    }
  ],
  "related_ids": [],
  "expected": null,
  "actual": null,
  "obligation": null,
  "counterexample": null,
  "explanation_uri": "sakura://explain/V0013",
  "fixes": []
}

Fixed program

compiler/tests/ui/V0013_invalid_assign_target.fixed.sakura, which sakura check accepts with no diagnostics:

fn first_to_zero() -> List<Int> {
  var xs = [1, 2]
  xs = List.set(xs, 0, 0)
  xs
}
Edit on GitHub

On this page