Sakura Lang

V1002 unresolved_name

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. Std names a collection's size len (List.len, String.len, Map.len), not length or size.

Wrong:

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

Fixed:

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

Wrong program

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

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

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

{
  "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.sak",
      "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": []
}

More fixtures for this code: compiler/tests/ui/V1002_module_function_did_you_mean.sak, compiler/tests/ui/V1002_module_function_no_near_candidate.sak, compiler/tests/ui/V1002_module_function_prefix.sak, compiler/tests/ui/V1002_non_prelude_std_name.sak, compiler/tests/ui/V1002_std_constructor_hint.sak, compiler/tests/ui/V1002_std_item_two_homes.sak, compiler/tests/ui/V1002_std_type_over_variant.sak.

Fixed program

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

fn total(subtotal: Int) -> Int { subtotal + 1 }
Edit on GitHub

Last updated

On this page