zig
zig copied to clipboard
LLVM Basic Block has no termintor error when calling `@errorName` with `@as(error{}, undefined)`
Zig Version
0.12.0
Steps to Reproduce and Observed Behavior
// bug.zig
test {
const err: error{} = undefined;
_ = @errorName(err);
}
$ zig test bug.zig
LLVM Emit Object... Basic Block in function 'bug.test_0' does not have terminator!
label %Entry
LLVM ERROR: Broken module found, compilation aborted!
Expected Behavior
I would expect this to not crash the compiler. Ideally this would be a compile error, as the only way this happens is when you call @errorName on an error{} object, and the only way to create an instance of error{} is from coercing undefined. The current behavior of @errorName with non-empty error sets could kept as is.
Related: #15909
Covered by #13807 and #15909