Sakura Lang

V0004 invalid_character

The source contains a character that cannot start any token.

An error from the lex phase. sakura explain V0004 prints this explanation offline.

The source contains a character that cannot start any token. Remove it, or put it inside a string.

Wrong:

fn price() -> Int { 1 $ 2 }

Fixed:

fn price() -> Int { 1 + 2 }

Wrong program

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

fn price() -> Int { 1 $ 2 }

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

{
  "schema_version": "1.0",
  "kind": "diagnostic",
  "id": "d:c4891f640c5e538f",
  "code": "V0004",
  "severity": "error",
  "phase": "lex",
  "message": "unexpected character `$`",
  "snapshot": "sha256:$SNAPSHOT",
  "symbol_id": "main::V0004_invalid_character::price",
  "spans": [
    {
      "uri": "file://$DIR/V0004_invalid_character.sakura",
      "content_hash": "sha256:7f1f0ceccb34c4fd667b6e3de781ca528e3486cb76e3981f65310a9c99a3fbdb",
      "start_byte": 56,
      "end_byte": 57,
      "role": "primary"
    }
  ],
  "related_ids": [],
  "expected": null,
  "actual": null,
  "obligation": null,
  "counterexample": null,
  "explanation_uri": "sakura://explain/V0004",
  "fixes": []
}

Fixed program

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

fn price() -> Int { 1 + 2 }
Edit on GitHub

On this page