-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
I've noticed some strange behavior with zig fmt on a catch block inside a while loop without a block:
Current behavior:
pub fn sendViewTags(self: Self) void {
...
var it = ViewStack(View).iterator(self.output.views.first, std.math.maxInt(u32));
while (it.next()) |node|
view_tags.append(node.view.current_tags) catch {
c.wl_resource_post_no_memory(self.wl_resource);
log.crit(.river_status, "out of memory", .{});
return;
};
...
}Desired behavior:
pub fn sendViewTags(self: Self) void {
...
var it = ViewStack(View).iterator(self.output.views.first, std.math.maxInt(u32));
while (it.next()) |node|
view_tags.append(node.view.current_tags) catch {
c.wl_resource_post_no_memory(self.wl_resource);
log.crit(.river_status, "out of memory", .{});
return;
};
...
}Works fine if you use a block with the while loop:
pub fn sendViewTags(self: Self) void {
...
var it = ViewStack(View).iterator(self.output.views.first, std.math.maxInt(u32));
while (it.next()) |node| {
view_tags.append(node.view.current_tags) catch {
c.wl_resource_post_no_memory(self.wl_resource);
log.crit(.river_status, "out of memory", .{});
return;
};
}
...
}Alternative also disallowed by zig fmt currently that I think should be allowed:
pub fn sendViewTags(self: Self) void {
...
var it = ViewStack(View).iterator(self.output.views.first, std.math.maxInt(u32));
while (it.next()) |node| view_tags.append(node.view.current_tags) catch {
c.wl_resource_post_no_memory(self.wl_resource);
log.crit(.river_status, "out of memory", .{});
return;
};
...
}Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.