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

zig gives invalid error for switch which should have type `noreturn` #635

Closed
andrewrk opened this Issue Nov 30, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@andrewrk
Member

andrewrk commented Nov 30, 2017

fn foo() -> %i32 {
    return 1;
}

export fn entry() {
    const x = foo() %% |err| switch (err) {
        else => unreachable,
    };
}

pub fn panic(msg: []const u8) -> noreturn { while (true) {} }
/home/andy/dev/zig/build/test.zig:6:21: error: incompatible types: 'void' and 'i32'
    const x = foo() %% |err| switch (err) {
                    ^
/home/andy/dev/zig/build/test.zig:6:30: note: type 'void' here
    const x = foo() %% |err| switch (err) {
                             ^
/home/andy/dev/zig/build/test.zig:6:21: note: type 'i32' here
    const x = foo() %% |err| switch (err) {
                    ^

@andrewrk andrewrk added the bug label Nov 30, 2017

@andrewrk andrewrk added this to the 0.2.0 milestone Nov 30, 2017

@andrewrk andrewrk closed this in 716b0b8 Nov 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment