aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/invalid_branch_hint.zig
blob: 1ceb8a686e5b744fa8ba628aad904a427203bc2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const globl = g: {
    @branchHint(.none);
    break :g {};
};

comptime {
    @branchHint(.none);
}

test {
    @branchHint(.none);
}

export fn foo() void {
    {
        @branchHint(.none);
    }
}

export fn bar() void {
    _ = (b: {
        @branchHint(.none);
        break :b true;
    }) or true;
}

export fn qux() void {
    (b: {
        @branchHint(.none);
        break :b @as(?void, {});
    }) orelse unreachable;
}

// error
//
// :2:5: error: '@branchHint' outside function scope
// :7:5: error: '@branchHint' outside function scope
// :11:5: error: '@branchHint' must appear as the first statement in a function or conditional branch
// :16:9: error: '@branchHint' must appear as the first statement in a function or conditional branch
// :22:9: error: '@branchHint' must appear as the first statement in a function or conditional branch
// :29:9: error: '@branchHint' must appear as the first statement in a function or conditional branch