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

Bad try inside function that doesn't return error union not caught for function with !T return type #11795

Closed
wooster0 opened this issue Jun 5, 2022 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@wooster0
Copy link
Contributor

wooster0 commented Jun 5, 2022

Zig Version

0.10.0-dev.2398+b08d32ceb

Steps to Reproduce

pub fn main() void {
    _ = try getNothing();
}

fn getNothing() !void {}

Expected Behavior

./x.zig:2:9: error: expected type 'void', found 'anyerror'
    _ = try getNothing();
        ^
./x.zig:1:15: note: function cannot return an error
pub fn main() void {
              ^

Actual Behavior

It compiles and does nothing. The error only shows up when changing !void to anyerror!void (or similar). Looks like a little oversight.

This happens in stage1 and stage2.

@wooster0 wooster0 added the bug Observed behavior contradicts documented or intended behavior label Jun 5, 2022
@wooster0 wooster0 changed the title Erroneous try inside function that doesn't return error union not caught for function with !T return type Bad try inside function that doesn't return error union not caught for function with !T return type Jun 5, 2022
@Vexu
Copy link
Member

Vexu commented Jun 5, 2022

Duplicate of #7541

@Vexu Vexu marked this as a duplicate of #7541 Jun 5, 2022
@Vexu Vexu closed this as completed Jun 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

2 participants