aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/recursive_inline_fn.zig
blob: 1cecfdbada3caa847e288b64c2cf0995de0b5be5 (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
inline fn foo(x: i32) i32 {
    if (x <= 0) {
        return 0;
    } else {
        return x * 2 + foo(x - 1);
    }
}

pub export fn entry() void {
    var x: i32 = 4;
    _ = &x;
    _ = foo(x) == 20;
}

inline fn first() void {
    second();
}

inline fn second() void {
    third();
}

inline fn third() void {
    first();
}

pub export fn entry2() void {
    first();
}

// error
// backend=stage2
// target=native
//
// :5:27: error: inline call is recursive
// :24:10: error: inline call is recursive