DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B0602: invalid escape sequence

Catalog status: active. Default severity: error. Stable name: invalid-escape. Family: Syntax and source text.

A backslash in a character or string literal starts an escape, and this one is not one the file's syntax reads.

In Varc the escapes are \n, \t, \r, \0, \\, \", \', \xHH (two hex digits) and \u{H...} (a code point).

In Vibe they are Python's: \n, \t, \r, \a, \b, \f, \v, \\, \', \", \xHH, \uHHHH, \UHHHHHHHH, up to three octal digits, and a backslash at the end of a line, which joins the lines; as in Python, a backslash before any other character stays in the text. The one Python escape Vibe does not read is a named escape, \N{...}.

Example (Varc)

let path: String = "C:\temp\data";

Example (Vibe)

    print("caf\N{LATIN SMALL LETTER E WITH ACUTE}")

What to do

In Varc, write \\ for a backslash: "C:\\temp\\data". In Vibe, write the character itself, or its code point: "caf\u00e9".

Regression source and further reading

Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.

See syntax and source text, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.