✓
Passing This code compiles and runs correctly.
Code
// Test 825: Reserved Zig Keyword as Branch Name
//
// BUG: When a branch uses a Zig reserved keyword (like "error"),
// the emitter generates invalid Zig code.
//
// Expected: Emitter escapes reserved keyword as .@"error" - compiles fine
// Actual: Emitter generates .error which is invalid Zig syntax
//
// This test demonstrates that the parser correctly accepts "error" as
// a branch name, but the emitter needs to escape it for Zig.
const std = @import("std");
~import std/io
~pub tor process-file { path: string }
| success string
| error string // "error" is a Zig reserved keyword!
~proc process-file|zig {
const file = std.fs.cwd().openFile(path, .{}) catch |err| {
return .{ .@"error" = @errorName(err) };
};
defer file.close();
const data = file.readToEndAlloc(std.heap.page_allocator, 1024) catch |err| {
return .{ .@"error" = @errorName(err) };
};
return .{ .success = data };
}
// Test without inline flows - just test keyword escaping
~process-file(path: "/nonexistent/file.txt")
| success _ |> std/io:print.ln("Unexpected file found")
| error _ |> std/io:print.ln("✅ Reserved Zig keyword branch works!")
Actual
✅ Reserved Zig keyword branch works!
Expected output
✅ Reserved Zig keyword branch works!
Flows
flow ~process-file click a branch to expand · @labels scroll to their anchor
process-file (path: "/nonexistent/file.txt")
Test Configuration
MUST_RUN