OxL Reference

error invalid-escape

error Standard: [§1.5]

What it means#

Inside ordinary and character literals only these escapes exist: \n \r \t \\ \" \' \0 \xHH \u{H...} (§1.5). Any other backslash sequence, a \x without two hex digits, or a \u{...} that is not a Unicode scalar value is rejected.

Example#

oxl✓ checked in CI
fn main() {
  let path = "C:\path\file.txt"      // <- invalid-escape (\p and \f are not escapes)
}
error
invalid-escape

How to fix#

oxl✓ checked in CI
fn main() {
  let path = r"C:\path\file.txt"
}

Double the backslash (\\) or use a raw string r"...", in which backslashes are literal. The contents of prefixed literals such as re"\d+" are raw by definition (decision D-003).

See also#

OxL 1.0.0-beta · Documentation version 1.0.0-beta© OxwaldLink · generated from the Standard, the std sources and the guides