Sakura Lang

V0014 named_argument

Calls take positional arguments only (design §3.2 rule 13, §17.21); name: value exists only inside attribute arguments.

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

Calls take positional arguments only (design §3.2 rule 13, §17.21); name: value exists only inside attribute arguments. Pass the value positionally, or pass a record when the call needs an options bag.

Wrong:

clamp(x, lo: 0, hi: 10)

Fixed:

clamp(x, 0, 10)

Wrong program

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

fn double(n: Int) -> Int { n * 2 }

fn four() -> Int { double(n: 2) }

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

{
  "schema_version": "1.0",
  "kind": "diagnostic",
  "id": "d:60f850145f8785bb",
  "code": "V0014",
  "severity": "error",
  "phase": "parse",
  "message": "arguments are positional; pass the value positionally or as a record",
  "snapshot": "sha256:$SNAPSHOT",
  "symbol_id": "main::V0014_named_argument::four",
  "spans": [
    {
      "uri": "file://$DIR/V0014_named_argument.sakura",
      "content_hash": "sha256:92140ff8ef26bf98b95db3ae0e646b29364103e543747cfc5f18ff85a4e84934",
      "start_byte": 96,
      "end_byte": 98,
      "role": "primary"
    }
  ],
  "related_ids": [],
  "expected": null,
  "actual": null,
  "obligation": null,
  "counterexample": null,
  "explanation_uri": "sakura://explain/V0014",
  "fixes": []
}

Fixed program

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

fn double(n: Int) -> Int { n * 2 }

fn four() -> Int { double(2) }
Edit on GitHub

On this page