Sorry for stupid topic name. Couldn’t imagine anything better.
const S1 = struct {
a: u32,
pub fn init() @This() {
return .{ .a = 5 };
}
};
const S2 = struct {
a: u32,
pub fn init() anyerror!@This() {
return .{ .a = 5 };
}
};
pub fn main() void {
const s1: S1 = .init(); //ok
const s2: S2 = .init() catch unreachable; // error: type '@EnumLiteral()' not a function
}
So the problem is simple when you have error union compiler struggles to kinda infer type and disallows neat “stripped” syntax (I would appreciate a name of this syntax in replies). So I want to know if it is intended design and it is me being dumb or I should go and create issue?