zig icon indicating copy to clipboard operation
zig copied to clipboard

LLVM Basic Block has no termintor error when calling `@errorName` with `@as(error{}, undefined)`

Open Trevor-Strong opened this issue 1 year ago • 1 comments

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.

Trevor-Strong avatar May 13 '24 20:05 Trevor-Strong

Related: #15909

wooster0 avatar May 14 '24 11:05 wooster0

Covered by #13807 and #15909

Vexu avatar May 19 '24 16:05 Vexu