aboutsummaryrefslogtreecommitdiff
path: root/test/incremental/recursive_function_becomes_non_recursive
blob: a5a03749b8ebc0f4b9cd90cd09b5e5df98ecfea4 (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
#target=x86_64-linux-selfhosted
#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
pub fn main() !void {
    try foo(false);
}
fn foo(recurse: bool) !void {
    const stdout = std.fs.File.stdout();
    if (recurse) return foo(true);
    try stdout.writeAll("non-recursive path\n");
}
const std = @import("std");
#expect_stdout="non-recursive path\n"

#update=eliminate recursion and change argument
#file=main.zig
pub fn main() !void {
    try foo(true);
}
fn foo(recurse: bool) !void {
    const stdout = std.fs.File.stdout();
    if (recurse) return stdout.writeAll("x==1\n");
    try stdout.writeAll("non-recursive path\n");
}
const std = @import("std");
#expect_stdout="x==1\n"