# V0012 keyword_expression_operand

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

> if, match, with, try, fn, handler and fail expressions cannot be operands of a binary or postfix operator without parentheses (design §3.2).

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

`if`, `match`, `with`, `try`, `fn`, `handler` and `fail` expressions cannot be operands of a
binary or postfix operator without parentheses (design §3.2).

Wrong:

```sakura
match x { … }.len()
```

Fixed:

```sakura
(match x { … }).len()
```

## Wrong program [#wrong-program]

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

```sakura
fn size(o: Option<Int>) -> Int {
  match o { Some(n) => n, None => 0 }.abs()
}
```

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

```json
{
  "schema_version": "1.0",
  "kind": "diagnostic",
  "id": "d:e46435be8e9e83af",
  "code": "V0012",
  "severity": "error",
  "phase": "parse",
  "message": "wrap the `match` expression in parentheses to use it as an operand",
  "snapshot": "sha256:$SNAPSHOT",
  "symbol_id": "main::V0012_keyword_expression_operand::size",
  "spans": [
    {
      "uri": "file://$DIR/V0012_keyword_expression_operand.sakura",
      "content_hash": "sha256:377d8532f3ab925ee33afb4febdc4749eafb1664be51c76f6a3398e3492c9ecf",
      "start_byte": 104,
      "end_byte": 105,
      "role": "primary"
    }
  ],
  "related_ids": [],
  "expected": null,
  "actual": null,
  "obligation": null,
  "counterexample": null,
  "explanation_uri": "sakura://explain/V0012",
  "fixes": []
}
```

## Fixed program [#fixed-program]

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

```sakura
fn size(o: Option<Int>) -> Int {
  (match o {
    Some(n) => n,
    None => 0,
  }).abs()
}
```
