# V3012 with_non_handler

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

> with was given something that is not a Handler<E, r> value.

An error from the `effect` phase. `sakura explain V3012` prints this explanation offline.

`with` was given something that is not a `Handler<E, r>` value. Pass a `handler E { … }`
expression or a function that returns one (std's handlers such as `Fs.rooted(dir)` and
`Log.captured()`); to compute a value without handling an effect, drop the `with`.

Wrong:

```sakura
fn five() -> Int { with 5 { 1 } }
```

Fixed:

```sakura
fn five() -> Int { 5 }
```

## Wrong program [#wrong-program]

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

```sakura
fn five() -> Int { with 5 { 1 } }
```

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

```json
{
  "schema_version": "1.0",
  "kind": "diagnostic",
  "id": "d:6c073b9264548e20",
  "code": "V3012",
  "severity": "error",
  "phase": "effect",
  "message": "`with` needs a handler value of type `Handler<E>`, found `Int`",
  "snapshot": "sha256:$SNAPSHOT",
  "symbol_id": "main::V3012_with_non_handler::five",
  "spans": [
    {
      "uri": "file://$DIR/V3012_with_non_handler.sakura",
      "content_hash": "sha256:b6b87db1126e93864c1251319991b29dcf78edb208c80c00c5ed781d74dbe7f1",
      "start_byte": 58,
      "end_byte": 59,
      "role": "primary"
    }
  ],
  "related_ids": [],
  "expected": null,
  "actual": {
    "render": "Int"
  },
  "obligation": null,
  "counterexample": null,
  "explanation_uri": "sakura://explain/V3012",
  "fixes": []
}
```

## Fixed program [#fixed-program]

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

```sakura
fn five() -> Int { 5 }
```
