Closed evanxg852000 closed 1 year ago
I think the application developer should expect this to be the case when returning an error from main. Returning ints from main changes the exit code, and an error is something significant that should not go ignored. If you want to ignore errors, you could use catch instead of try:
const std = @import("std");
const Error = error{Foo};
fn fallible() !void {
return Error.Foo;
}
pub fn main() void {
fallible() catch {};
}
Zig Version
0.11.0
Steps to Reproduce and Observed Output
Running this snippet with Zig will output
error: Foo
The expectation as an application developer is that nothing should be printed on my behalf. I have already printed a better error message to the user. Probably I don't even want the user knowing the type of Error. At this point, all I care about is that an error code is returned to the shell. But do not print something.
For an anecdote, this is the output of this simple CLI application when ran in a shell https://github.com/evanxg852000/clack/blob/main/src/examples/demo.zig#L11-L35
The last line is undesired here IMHO, especially in release mode. It would be nice to limit this only to debug builds. But a compiler printing on my behalf in release mode, meh.
Expected Output
Nothing