You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const io = @import("std").io;
fn getPrint() type {
return struct {
const f = try io.getStdOut(); // there's an error here if we remove "catch unreachable" in main
// const f = io.getStdOut() catch unreachable; // also 'works', moving the error to the next line instead
const stdout = &io.FileOutStream.init(&f).stream;
pub fn rint(s: []const u8) void {
stdout.print(s) catch unreachable;
}
};
}
pub fn main() void {
const p = getPrint() catch unreachable; // segfault
// p.rint("s"); // desired payload of this closure hack (no per-call "catch unreachable" boilerplate)
}
P.S. I couldn't figure out the argument signature for passing stdout to a function that handles the "catch unreachable" boilerplate - using OutStream(error{...}) doesn't match the "anonymous error union" with the expected type... (#764)
The text was updated successfully, but these errors were encountered:
Hejsil
changed the title
Compiler segfaults when "catch unreachable" prevents compiler errors in struct global declaration
Compiler assert when trying to unwrap return type typeMay 30, 2018
No
std.debug.warn
for me:zig version
0.2.0.a6ae4514
P.S. I couldn't figure out the argument signature for passing(#764)stdout
to a function that handles the "catch unreachable" boilerplate - usingOutStream(error{...})
doesn't match the "anonymous error union" with the expected type...The text was updated successfully, but these errors were encountered: