# V0013 invalid_assign_target

URL: /docs/errors/V0013
Markdown: /docs/errors/V0013.md

> 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 [#wrong-program]

[`compiler/tests/ui/V0013_invalid_assign_target.sakura`](https://github.com/icantcodefyi/sakuralang/blob/master/compiler/tests/ui/V0013_invalid_assign_target.sakura), which the compiler's ui suite runs through `sakura check`:

```sakura
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):

```json
{
  "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 [#fixed-program]

[`compiler/tests/ui/V0013_invalid_assign_target.fixed.sakura`](https://github.com/icantcodefyi/sakuralang/blob/master/compiler/tests/ui/V0013_invalid_assign_target.fixed.sakura), which `sakura check` accepts with no diagnostics:

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