Skip to content

comptime re-interprets escapes in a raw string literal: const C: str = r#"a\\"b"# yields a"b #1246

Closed

Description

@ehartford
const C: str = r#"a\"b\n"#
let L: str = r#"a\"b\n"#
fn main:
    print(C)     // a"b<newline>   (escapes processed)
    print(L)     // a\"b\n         (correct: raw)

const desugars to a comptime-wrapped let (Parser.w parse_const_decl); the comptime materialization of the string value processes \" and \n as escapes although the literal is raw (§3.2). Same on the installed compiler and a fresh release build.

Found on the #1242 branch when the embedded stdlib/runtime/clang-resource generators were switched from let to const: <embedded-std>/std/build.w came out with its \" unescaped and every use std.build program failed to parse. The generators stay on let (+ .clone() on the returns) until this is fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions