# V0014 named_argument

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

> 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:

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

Fixed:

```sakura
clamp(x, 0, 10)
```

## Wrong program [#wrong-program]

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

```sakura
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):

```json
{
  "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 [#fixed-program]

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

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

fn four() -> Int { double(2) }
```
