zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 9014daedbbb0630ee438ab64302dd0e0697759ba (tree)
parent 409541bc77cb1d6a447dbcdf74f9fcbc2a8b0397
Author: Kendall Condon <goon.pri.low@gmail.com>
Date:   Mon, 28 Jul 2025 14:07:46 -0400

zig fmt: properly check escape sequences

Diffstat:
Mlib/std/zig/Ast/Render.zig | 2+-
Mlib/std/zig/parser_test.zig | 10++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/std/zig/Ast/Render.zig b/lib/std/zig/Ast/Render.zig @@ -3167,7 +3167,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), diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig @@ -6086,6 +6086,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;