# V1004 name_case_mismatch

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

> Values are lower_snake identifiers and types, variants, error tags and effects are UpperCamel (design §2.1).

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

Values are `lower_snake` identifiers and types, variants, error tags and effects are `UpperCamel`
(design §2.1). A name was used in the wrong namespace for its case: std modules are reached
through their `UpperCamel` namespace (`List.len`, `String.trim`), not the module path.

Wrong:

```sakura
fn count() -> Int { list.len([1, 2]) }
```

Fixed:

```sakura
fn count() -> Int { List.len([1, 2]) }
```

## Wrong program [#wrong-program]

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

```sakura
fn count() -> Int { list.len([1, 2]) }
```

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

```json
{
  "schema_version": "1.0",
  "kind": "diagnostic",
  "id": "d:aada4e706e82b4da",
  "code": "V1004",
  "severity": "error",
  "phase": "resolve",
  "message": "cannot find `list`; `List` exists but names differ in case (values are lowercase, types are uppercase)",
  "snapshot": "sha256:$SNAPSHOT",
  "symbol_id": "main::V1004_name_case_mismatch::count",
  "spans": [
    {
      "uri": "file://$DIR/V1004_name_case_mismatch.sakura",
      "content_hash": "sha256:b661d72702f5a8e4b3d2d30860c4c549c89a174a52dfa4c7eab5f1ce861fb3fb",
      "start_byte": 54,
      "end_byte": 58,
      "role": "primary"
    }
  ],
  "related_ids": [],
  "expected": null,
  "actual": null,
  "obligation": null,
  "counterexample": null,
  "explanation_uri": "sakura://explain/V1004",
  "fixes": [
    {
      "id": "f:aada4e706e82b4da.0",
      "title": "Use `List`",
      "applicability": "machine_applicable",
      "impact": "local",
      "edits": [
        {
          "span": {
            "uri": "file://$DIR/V1004_name_case_mismatch.sakura",
            "content_hash": "sha256:b661d72702f5a8e4b3d2d30860c4c549c89a174a52dfa4c7eab5f1ce861fb3fb",
            "start_byte": 54,
            "end_byte": 58,
            "role": "primary"
          },
          "replacement": "List"
        }
      ]
    }
  ]
}
```

## Fixed program [#fixed-program]

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

```sakura
fn count() -> Int { List.len([1, 2]) }
```
