-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
stage2: unreachable in checkComptimeVarStore #12787
Comments
|
Here's a small patch that should turn that crash into a (likely invalid) compile error: diff --git a/src/Sema.zig b/src/Sema.zig
index 15e891ef8..737f572e2 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -5218,6 +5218,10 @@ fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError
if (block.runtime_cond == null and block.runtime_loop == null) {
block.runtime_cond = start_block.runtime_cond orelse start_block.runtime_loop;
block.runtime_loop = start_block.runtime_loop;
+ if (block.runtime_cond == null and block.runtime_loop == null) {
+ const block_data = sema.code.instructions.items(.data)[zir_block].pl_node;
+ block.runtime_cond = block_data.src();
+ }
}
return inst;
}Maybe it'll help in finding out what is causing the crash? |
|
Thanks. I’ll give it a shot. Note you labeled this stage1 but this passes with stage1 and fails with stage2 so this should be labeled stage2. |
|
Thanks @Vexu I've minimized it. const std = @import("std");
test {
const Widget = union(enum) { a: u0 };
const block: Widget = block: {
const info = @typeInfo(Widget).Union;
inline for (info.fields) |field| {
if (std.mem.eql(u8, "anything", field.name)) {
switch (field.field_type) {
u0 => break :block @unionInit(Widget, field.name, 0),
else => unreachable,
}
}
}
unreachable;
};
_ = block;
} |
|
Note: the Further, if you reduce it further and remove the |
Zig Version
0.10.0-dev.3900+ab4b26d8a
Steps to Reproduce
zig test repro.zig-- failszig test repro.zig -fstage1-- passesNote: the u0 can be any type it appears...
Further, if you reduce it further and remove the switch, you actually get a "store to comptime variable depends on runtime condition" rather than a crash on unreachable. So there are perhaps two bugs here, with one masking the other.
Expected Behavior
Tests pass (to match stage1)
Actual Behavior
The text was updated successfully, but these errors were encountered: