We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The following code triggers a seemingly infinite Semantic Analysis step that never completes.
const std = @import("std"); const Node = union(enum) { leaf: u8, node: ?*Node, pub fn format(self: Node, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) @TypeOf(writer).Error!void { switch (self) { .leaf => { try writer.writeAll("leaf=\""); try std.fmt.format(writer, "{}", .{self.leaf}); try writer.writeAll("\""); }, .node => { try writer.writeAll("node=["); if (self.node) |n| try n.format("{}", std.fmt.FormatOptions{}, writer); try writer.writeAll("]"); }, } } }; pub fn main() anyerror!void { var leaf = Node{ .leaf = 127 }; var node = Node{ .node = &leaf }; var root = Node{ .node = &node }; std.debug.print("{}\n", .{root}); }
I expect node=[node=[leaf="127"]] to be printed.
node=[node=[leaf="127"]]
If you comment out either the call to std.fmt.format in the .leaf arm or the recursive call to Node.format in the .node arm, the code compiles.
std.fmt.format
.leaf
Node.format
.node
The text was updated successfully, but these errors were encountered:
Duplicate of #4572.
Sorry, something went wrong.
No branches or pull requests
The following code triggers a seemingly infinite Semantic Analysis step that never completes.
I expect
node=[node=[leaf="127"]]
to be printed.If you comment out either the call to
std.fmt.format
in the.leaf
arm or the recursive call toNode.format
in the.node
arm, the code compiles.The text was updated successfully, but these errors were encountered: