V1004 name_case_mismatch
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:
fn count() -> Int { list.len([1, 2]) }Fixed:
fn count() -> Int { List.len([1, 2]) }Wrong program
compiler/tests/ui/V1004_name_case_mismatch.sakura, which the compiler's ui suite runs through sakura check:
fn count() -> Int { list.len([1, 2]) }sakura check --json reports this record (pretty-printed; $DIR is the fixture's directory):
{
"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
compiler/tests/ui/V1004_name_case_mismatch.fixed.sakura, which sakura check accepts with no diagnostics:
fn count() -> Int { List.len([1, 2]) }