How do you make the following function compile?
fn hello() enum {} {
// ???
}
How do you make the following function compile?
fn hello() enum {} {
// ???
}
En Garde!
fn hello() enum {} {
const T = @typeInfo(@TypeOf(hello)).Fn.return_type.?;
const t: T = undefined;
return t;
}
pub fn main() !void {
_ = hello();
}
Or, even simpler!
fn hello() enum {} {
return undefined;
}
pub fn main() !void {
_ = hello();
}
You can fill // ???
with anything that does not return, such as panic.
fn hello() enum {} {
unreachable;
}
test {
_ = hello();
}