digitalmars.D.bugs - [Issue 22776] New: string literal printing fails on
- d-bugmail puremagic.com (34/34) Feb 15 2022 https://issues.dlang.org/show_bug.cgi?id=22776
https://issues.dlang.org/show_bug.cgi?id=22776 Issue ID: 22776 Summary: string literal printing fails on non-ASCII/non-printable chars Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: dkorpel live.nl When dmd prints a string literal in an error message it doesn't handle non-trivial cases properly: ``` "before \0 after"; "\n"; ``` Error: declaration expected, not `"before "` Error: declaration expected, not `"\x0a"` It truncates at zero bytes and uses \x00 codes for everything non-printable, even when there are more readable escape sequences available (most commonly \n for \x0A). non-ASCII code units in wstrings and dstrings also get messed up in semantic errors: ``` pragma(msg, "\u1234"w.stringof); // "\x34\x12"w pragma(msg, "\u1234"d.stringof); // "\x34\x12"d ``` The lexer handles these correctly by emitting \u sequences instead of \x sequences. --
Feb 15 2022