-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fails to compile return of optional in certain conditionals #10601
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
Comments
I analyzed the llvm IR, but failed to debug further than that. Here is the relevant IR logs: ZIR:
resumed portion of analysis log:
AIR which is equivalent to the outputted LLVM IR (has the same undominated instructions on one branch)
produced LLVM IR
I was able to compile the output llvm ir with |
If someone who can fix this faster than me isn't available, I can work on a pull request slowly. |
here's an additional smaller reproduction: fn f(param: u32) ?u32 {
return if (param == 1) @as(u32, 2)
else if (param == 2) @as(u32, 4)
else if (param == 3) @as(u32, 5)
else @as(u32, 6);
}
pub fn main() void { _ = f(7); } I much better understand what's going on in the compiler that triggers this, but not enough yet to produce a fix. still slowly reading through the analysis code to figure it out |
Can be worked around by casting to |
Zig Version
0.10.0-dev.290+3901b6fb0
Steps to Reproduce
Expected Behavior
for it to compile as valid code
Actual Behavior
the compiler crashes:
EDIT: smaller reproduction:
The text was updated successfully, but these errors were encountered: