unhelpful error message on invalid bytes inside multi line string literal
Zig Version
0.14.0-dev.764+eb1a199df
Steps to Reproduce and Observed Output
// example.zig
const foo =
\\const S = struct {
\\<TAB>// hello
\\}
;
Running zig fmt --check example.zig outputs:
example.zig:3:1: error: expected ';' after declaration
\\ // hello
^
This message had me so confused that I though that there was a bug in the parser or tokenizer. Luckily it was just #20885 rejecting tabs inside multiline string literals.
Expected Output
I would expect an error message that does fulfills these requirements:
- mention that invalid bytes have been encountered
- mention where the invalid byte is located
- mention the value of the byte
Something like this:
:3:6: error: found 'invalid bytes' inside multiline string literals
:3:6: note: invalid byte: '\\x09'
This bug also bite me, does this mean we are not allowed to use tab in multi line string?
does this mean we are not allowed to use tab in multi line string?
Yes, see https://github.com/ziglang/zig-spec/issues/38 for details.
The unhelpful error also occurs when a comment has an invalid byte.
I just spent longer than I want to admit tracking down a bug that ended up being a tab in a comment... I feel like this is an error that zig fmt could have easily fixed, but it currently doesn't.