so I was working on something with Zig and encountered a weird fmt bug which I could not replicate consistently with zig fmt unlike the lsp
for context, here is a file I made to check for it:
before save:
fn name() !void {
const @"é" = .{ @intCast(32)}; // breaks
const @"é" = .{ sometext}; // breaks
const @"é" = .{@intCast(32) }; // breaks
const @"é" = .{sometext }; // breaks
const @"é" = .{@intCast(32)}; // fine
const @"é" = .{sometext}; // fine
std.debug.print("ééé {s}", .{ @builtinthing(12) });
std.debug.print("يمينص {s}", .{ @builtinthing(12)} );
std.debug.print("يمينص {s}", .{ @intCast(12) });
std.debug.print("س {s}", .{ @import("dank").daj() } );
}
after save:
fn name() !void {
const @"é" = .{ intCast(32)}; // breaks
const @"é" = .{ ometext}; // breaks
const @"é" = .{@intCast(32) ; // breaks
const @"é" = .{sometext ; // breaks
const @"é" = .{@intCast(32)}; // fine
const @"é" = .{sometext}; // fine
std.debug.print("ééé {s}", .{ @biltinthing(12) })
std.debug.print("يمينص {s}", .{ @buitinthing(12)} );
std.debug.print("يمينص {s}", .{ ast(12) });
std.debug.print("س {s}", .{ import("dank").daj() ;
}
I use Neovim with zls and directly using zig fmt works fine here. I tried using zig fmt directly to find the issue, but while experimenting I lost the where zig fmt breaks the file (it would be great if it was only broken cuse zls touched it though)
zig fmt would break the file then print an error for invalid token. but since I can’t “undo” after calling the shell command, I couldn’t get the the input which caused the error