Skip to content

Commit 270f4ac

Browse files
committed
zig fmt: properly check escape sequences
1 parent d36cbe3 commit 270f4ac

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

lib/std/zig/parser_test.zig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6138,6 +6138,16 @@ test "zig fmt: seperate errors in error sets with comments" {
61386138
);
61396139
}
61406140

6141+
test "zig fmt: proper escape checks" {
6142+
try testTransform(
6143+
\\@"\x41\x42\!"
6144+
\\
6145+
,
6146+
\\@"AB\!"
6147+
\\
6148+
);
6149+
}
6150+
61416151
test "recovery: top level" {
61426152
try testError(
61436153
\\test "" {inline}

lib/std/zig/render.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2821,7 +2821,7 @@ fn renderIdentifier(r: *Render, token_index: Ast.TokenIndex, space: Space, quote
28212821
},
28222822
.failure => return renderQuotedIdentifier(r, token_index, space, false),
28232823
}
2824-
contents_i += esc_offset;
2824+
contents_i = esc_offset;
28252825
continue;
28262826
},
28272827
else => return renderQuotedIdentifier(r, token_index, space, false),

0 commit comments

Comments
 (0)