[Issue 22776] New: string literal printing fails on non-ASCII/non-printable chars
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 15 20:26:10 UTC 2022
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 at puremagic.com
Reporter: dkorpel at 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.
--
More information about the Digitalmars-d-bugs
mailing list