# V1002 unresolved_name

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

> No value with this name is in scope.

An error from the `resolve` phase. `sakura explain V1002` prints this explanation offline.

No value with this name is in scope. Check the spelling, add an `import`, or define it.

Wrong:

```sakura
fn main() -> Unit ! {Console} { Console.print(greting) }
```

Fixed:

```sakura
fn main() -> Unit ! {Console} { let greeting = "hi"; Console.print(greeting) }
```

## Wrong program [#wrong-program]

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

```sakura
fn total() -> Int { subtotal + 1 }
```

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

```json
{
  "schema_version": "1.0",
  "kind": "diagnostic",
  "id": "d:d37ae75eb7ba43ab",
  "code": "V1002",
  "severity": "error",
  "phase": "resolve",
  "message": "cannot find `subtotal` in this scope",
  "snapshot": "sha256:$SNAPSHOT",
  "symbol_id": "main::V1002_unresolved_name::total",
  "spans": [
    {
      "uri": "file://$DIR/V1002_unresolved_name.sakura",
      "content_hash": "sha256:a05007960f2dfb9768cc5b843ff90f123b87583f10bdfecfe5abb50d9e2dbc5e",
      "start_byte": 54,
      "end_byte": 62,
      "role": "primary"
    }
  ],
  "related_ids": [],
  "expected": null,
  "actual": null,
  "obligation": null,
  "counterexample": null,
  "explanation_uri": "sakura://explain/V1002",
  "fixes": []
}
```

## Fixed program [#fixed-program]

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

```sakura
fn total(subtotal: Int) -> Int { subtotal + 1 }
```
