Sakura Lang

V1007 wrong_kind

A name resolved to the wrong kind of item for where it is used: an effect where a type is expected, a type where a value is expected, and so on.

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

A name resolved to the wrong kind of item for where it is used: an effect where a type is expected, a type where a value is expected, and so on.

Wrong:

fn log(c: Console) -> Unit { … }

Fixed:

fn log(line: String) -> Unit ! {Console} { … }

Wrong program

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

type Box<e> = { run: fn() -> Unit ! e }

fn wrong(b: Box<Int>) -> Unit { () }

fn also(xs: List<{Console}>) -> Unit { () }

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

{
  "schema_version": "1.0",
  "kind": "diagnostic",
  "id": "d:91f2a1bc95cf6ba7",
  "code": "V1007",
  "severity": "error",
  "phase": "resolve",
  "message": "`Box` expects an effect row here (`{…}` or a row variable), not a type",
  "snapshot": "sha256:$SNAPSHOT",
  "symbol_id": "main::V1007_row_argument_kind::wrong",
  "spans": [
    {
      "uri": "file://$DIR/V1007_row_argument_kind.sakura",
      "content_hash": "sha256:be23ae9b6fb3d53ea9979c646b12d1f8bbc17a13497f93627b7a16ffda36b751",
      "start_byte": 97,
      "end_byte": 100,
      "role": "primary"
    }
  ],
  "related_ids": [],
  "expected": null,
  "actual": null,
  "obligation": null,
  "counterexample": null,
  "explanation_uri": "sakura://explain/V1007",
  "fixes": []
}

Fixed program

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

type Box<e> = { run: fn() -> Unit ! e }

fn right(b: Box<{Console}>) -> Unit ! {Console} { b.run() }

fn also(xs: List<Int>) -> Unit { () }
Edit on GitHub

On this page