Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to unwrap error missing the error in ReleaseSafe #19531

Open
Jarred-Sumner opened this issue Apr 4, 2024 · 1 comment
Open

attempt to unwrap error missing the error in ReleaseSafe #19531

Jarred-Sumner opened this issue Apr 4, 2024 · 1 comment
Labels
error message This issue points out an error message that is unhelpful and should be improved.

Comments

@Jarred-Sumner
Copy link
Contributor

Zig Version

0.12.0-dev.1830+779b8e259

Steps to Reproduce and Observed Output

  1. Code:
const std = @import("std");

pub fn main() !void {
    try doMath(std.math.add, std.math.maxInt(i32), 6);
}

fn doMath(comptime f: fn (type, i32, i32) error{Overflow}!i32, a: i32, b: i32) !void {
    const result = f(i32, a, b) catch unreachable;
    std.debug.print("Result: {}", .{result});
}
  1. Run:
zig run -OReleaseSafe repro.zig
  1. Error:
❯ zig run -OReleaseSafe repro.zig
thread 14126458 panic: attempt to unwrap error
fish: Job 1, 'zig run -OReleaseSafe repro.zig' terminated by signal SIGABRT (Abort)

Expected Output

thread 14136199 panic: attempt to unwrap error: Overflow
fish: Job 1, 'zig run -OReleaseSafe repro.zig' terminated by signal SIGABRT (Abort)

Related:

This does not happen in debug builds

@Jarred-Sumner Jarred-Sumner added the error message This issue points out an error message that is unhelpful and should be improved. label Apr 4, 2024
@Vexu
Copy link
Member

Vexu commented Apr 4, 2024

-fformatted-panics is only set by default in debug mode, see also #17969

// TODO: https://github.com/ziglang/zig/issues/17969
const formatted_panics = options.formatted_panics orelse (options.root_mod.optimize_mode == .Debug);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error message This issue points out an error message that is unhelpful and should be improved.
Projects
None yet
Development

No branches or pull requests

2 participants