# V0005 invalid_escape

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

> A string contains an escape that is not one of \\ \" \n \r \t \0 \{ \} or \u{XXXXXX} (design §2.3).

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

A string contains an escape that is not one of `\\ \" \n \r \t \0 \{ \}` or
`\u{XXXXXX}` (design §2.3). Write a literal `{` as `\{`.

## Wrong program [#wrong-program]

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

```sakura
fn path() -> String { "C:\qdata" }
```

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

```json
{
  "schema_version": "1.0",
  "kind": "diagnostic",
  "id": "d:2fa2c87a53cb8ac1",
  "code": "V0005",
  "severity": "error",
  "phase": "lex",
  "message": "unknown escape `\\q`",
  "snapshot": "sha256:$SNAPSHOT",
  "symbol_id": "main::V0005_invalid_escape::path",
  "spans": [
    {
      "uri": "file://$DIR/V0005_invalid_escape.sakura",
      "content_hash": "sha256:7b5638f558599caf34c57065c8fe17bf9f43cc141898a81150d2d2641f79ab93",
      "start_byte": 59,
      "end_byte": 61,
      "role": "primary"
    }
  ],
  "related_ids": [],
  "expected": null,
  "actual": null,
  "obligation": null,
  "counterexample": null,
  "explanation_uri": "sakura://explain/V0005",
  "fixes": []
}
```

## Fixed program [#fixed-program]

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

```sakura
fn path() -> String { "C:\\qdata" }
```
