aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/nested_error_set_mismatch.zig
blob: 3addd5ee4340582f62896fbd1c3ecb95fbd0bc6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const NextError = error{NextError};
const OtherError = error{OutOfMemory};

export fn entry() void {
    const a: ?NextError!i32 = foo();
    _ = a;
}

fn foo() ?OtherError!i32 {
    return null;
}

// error
// backend=llvm
// target=native
//
// :5:34: error: expected type '?error{NextError}!i32', found '?error{OutOfMemory}!i32'
// :5:34: note: optional type child 'error{OutOfMemory}!i32' cannot cast into optional type child 'error{NextError}!i32'
// :5:34: note: 'error.OutOfMemory' not a member of destination error set