mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 10:24:47 +01:00
32 lines
948 B
Text
32 lines
948 B
Text
#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.Io.File.stdout();
|
|
if (recurse) return foo(true);
|
|
try stdout.writeStreamingAll(io, "non-recursive path\n");
|
|
}
|
|
const std = @import("std");
|
|
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
|
#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.Io.File.stdout();
|
|
if (recurse) return stdout.writeStreamingAll(io, "x==1\n");
|
|
try stdout.writeStreamingAll(io, "non-recursive path\n");
|
|
}
|
|
const std = @import("std");
|
|
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
|
#expect_stdout="x==1\n"
|