zig
zig copied to clipboard
stage2 anyerror + @field() regression
Zig Version
0.11.0-dev.63+8c4faa5f3
Steps to Reproduce and Observed Behavior
I used to be able to create error unions using @field
:
const std = @import("std");
pub fn main() void {
const e = @field(anyerror, "NotFound");
std.debug.print("{}\n", .{@TypeOf(e)});
}
This was a handy way of creating error unions at compile time.
But now @TypeOf(e)
is always anyerror
Expected Behavior
Stage1 evaluates TypeOf(e)
to error{NotFound}
I can use @Type
for now, until its removed from the language.
const E = @Type(std.builtin.Type{
.ErrorSet = &[_]std.builtin.Type.Error{.{
.name = "NotFound",
}},
});
var e = @field(E, "NotFound");
https://github.com/ziglang/zig/issues/10710