-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Compiler Segfaults Checking Active Union Tag in format
Method
#19667
Comments
The issue appears to be caused by recursively calling the |
Thanks; can confirm the above lets me workaround this! :) |
Here's a minimum repro: const std = @import("std");
const Value = struct {
foo: *Value,
inline fn Bar(value: Value, indents: usize) !void {
@setEvalBranchQuota(2000000);
try value.foo.Bar(indents);
}
};
pub fn main() !void {
var value: Value = .{ .foo = undefined };
_ = &value;
value.Bar(0);
} Interesting behaviour to note, when you remove the |
#13724 related ? |
Possibly, the error itself is a stack overflow inside of the compiler. |
Closing as duplicate of #13724 |
Zig Version
0.12.0-dev.3653+e45bdc6bd
Steps to Reproduce and Observed Behavior
Attempting to write a
format
method for a taggedunion
that can be deeply nested, but attempting to handle printing viaformat
method by switching on the active tag (or by hardcoding conditional checks as a series ofif
/else if
blocks) causes the compiler to segfault.Reproduction of issue using
switch
syntax: (gist of lldb output)Hard coding this as a series of
if
/else if
statements causes the same segmentation fault when compiling: (gist of lldb output)Expected Behavior
The above snippets should compile/the data should be logged per the logic in
format
method.The text was updated successfully, but these errors were encountered: