You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently using noreturn and noreturn like types as variables is a bit broken.
Using noreturn directly gives a compiler error but applying the suggestions triggers an assertion:
pubexportfnentry() void {
varn: noreturn=undefined; // error: variable of type 'noreturn' must be const or comptime_=n;
}
pubexportfnentry() void {
comptimevarn: noreturn=undefined;
_=n;
}
// thread 27040 panic: reached unreachable code// lib/std/debug.zig:278:14: 0x79b7c16 in assert (zig)// if (!ok) unreachable; // assertion failure// ^// src/Sema.zig:5275:122: 0x80c7260 in analyzeBlockBody (zig)// assert(sema.typeOf(Air.indexToRef(child_block.instructions.items[child_block.instructions.items.len - 1])).isNoReturn());
An empty error set causes invalid LLVM IR and making it const or comptime hits the same assertion:
pubexportfnentry() void {
constE=error{};
vare: E=undefined;
_=e;
}
// LLVM Emit Object... // Basic Block in function 'entry' does not have terminator!// label %Entry// thread 27288 panic: LLVM module verification failed
Empty enums and unions are not currently recognized as noreturn types so this example compiles just fine but if recognized as such then it hits the same issues.
One solution that should handle generic code nicely would be to add a panic to loading a noreturn variable or dereferencing a noreturn pointer but I'm not sure if it's the best solution.
The text was updated successfully, but these errors were encountered:
Vexu
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Dec 7, 2022
Currently using
noreturn
andnoreturn
like types as variables is a bit broken.Using noreturn directly gives a compiler error but applying the suggestions triggers an assertion:
An empty error set causes invalid LLVM IR and making it const or comptime hits the same assertion:
Empty enums and unions are not currently recognized as
noreturn
types so this example compiles just fine but if recognized as such then it hits the same issues.One solution that should handle generic code nicely would be to add a panic to loading a
noreturn
variable or dereferencing anoreturn
pointer but I'm not sure if it's the best solution.The text was updated successfully, but these errors were encountered: