zig fmt: properly check escape sequences

This commit is contained in:
Kendall Condon 2025-07-28 14:07:46 -04:00
parent 6bcd6b35ce
commit 8d4531bff5
2 changed files with 11 additions and 1 deletions

View file

@ -3359,7 +3359,7 @@ fn renderIdentifier(r: *Render, token_index: Ast.TokenIndex, space: Space, quote
},
.failure => return renderQuotedIdentifier(r, token_index, space, false),
}
contents_i += esc_offset;
contents_i = esc_offset;
continue;
},
else => return renderQuotedIdentifier(r, token_index, space, false),

View file

@ -6152,6 +6152,16 @@ test "zig fmt: seperate errors in error sets with comments" {
);
}
test "zig fmt: proper escape checks" {
try testTransform(
\\@"\x41\x42\!"
\\
,
\\@"AB\\!"
\\
);
}
test "zig fmt: field accesses on number literals" {
try testCanonical(
\\const a = 0xF .A;