Skip to content
New issue

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

segfault when struct custom formatter attemps to recursively print itself #16933

Closed
xdBronch opened this issue Aug 23, 2023 · 3 comments
Closed
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@xdBronch
Copy link
Contributor

Zig Version

0.12.0-dev.162+ada001047

Steps to Reproduce and Observed Behavior

// format.zig
const std = @import("std");

pub fn main() !void {
    const segf = struct {
        pub fn format(self: @This(), _: anytype, _: anytype, writer: anytype) !void {
            try writer.print("{}", .{self});
        }
    };
    std.debug.print("{}", .{segf{}});
}

run zig run format.zig
result: segmentation fault (core dumped) zig run format.zig

Expected Behavior

some type of dependency loop compile error

@xdBronch xdBronch added the bug Observed behavior contradicts documented or intended behavior label Aug 23, 2023
@N00byEdge
Copy link
Sponsor Contributor

Infinite recursion is not an error in Zig.

@xdBronch
Copy link
Contributor Author

ah right, i used zig run so i didnt realize it was a runtime crash, apologies. should this be closed then?

@wooster0
Copy link
Contributor

Yes: #1006

@xdBronch xdBronch closed this as not planned Won't fix, can't repro, duplicate, stale Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants