✗
Failing This test is currently failing.
Failed: backend-exec
Failure Output
Showing last 10 of 13 lines
if (std.mem.eql(u8, (&req1).method, "GET") and std.mem.eql(u8, (&req1).path, "/other")) {
(struct { fn __kout(__fd: i32, __b: []const u8) void { if (@import("builtin").os.tag == .freestanding) { const __kc = struct { extern var stdout: ?*anyopaque; extern var stderr: ?*anyopaque; extern fn fputs(__s: [*:0]const u8, __st: ?*anyopaque) c_int; }; var __kt: [4096]u8 = undefined; var __ki: usize = 0; while (__ki < __b.len) { const __kn = @min(__kt.len - 1, __b.len - __ki); @memcpy(__kt[0..__kn], __b[__ki..][0..__kn]); __kt[__kn] = 0; @import("std").mem.doNotOptimizeAway(__kc.fputs(@as([*:0]const u8, @ptrCast(&__kt)), if (__fd == 2) __kc.stderr else __kc.stdout)); __ki += __kn; } } else { @import("std").mem.doNotOptimizeAway(@import("std").posix.write(__fd, __b) catch @as(usize, 0)); } } fn __kw(comptime __f: []const u8, __a: anytype) void { var __kb: [65536]u8 = undefined; const __ks = @import("std").fmt.bufPrint(&__kb, __f, __a) catch __kb[0..0]; __kout(1, __ks); } }).__kw("inner: /other\n", .{});
} else {
(struct { fn __kout(__fd: i32, __b: []const u8) void { if (@import("builtin").os.tag == .freestanding) { const __kc = struct { extern var stdout: ?*anyopaque; extern var stderr: ?*anyopaque; extern fn fputs(__s: [*:0]const u8, __st: ?*anyopaque) c_int; }; var __kt: [4096]u8 = undefined; var __ki: usize = 0; while (__ki < __b.len) { const __kn = @min(__kt.len - 1, __b.len - __ki); @memcpy(__kt[0..__kn], __b[__ki..][0..__kn]); __kt[__kn] = 0; @import("std").mem.doNotOptimizeAway(__kc.fputs(@as([*:0]const u8, @ptrCast(&__kt)), if (__fd == 2) __kc.stderr else __kc.stdout)); __ki += __kn; } } else { @import("std").mem.doNotOptimizeAway(@import("std").posix.write(__fd, __b) catch @as(usize, 0)); } } fn __kw(comptime __f: []const u8, __a: anytype) void { var __kb: [65536]u8 = undefined; const __ks = @import("std").fmt.bufPrint(&__kb, __f, __a) catch __kb[0..0]; __kout(1, __ks); } }).__kw("inner: catch-all\n", .{});
}
error[KORU124]: transform 'router' invoked in continuation position is not supported here
--> tests/regression/300_ADVANCED_FEATURES/350_SUBFLOWS/350_012_nested_router/input.kz:29:0
this transform uses the whole-program escape, which matches flow-root invocations only; a continuation-position invocation is never rewritten (frontier: 210_024_source_scope_capture).
fix: invoke 'router' at top level, or have it return a site-local SiteResult instead of a whole_program. Code
// ============================================================================
// REGRESSION TEST - Nested Router (Tree-Structured Routing)
// ============================================================================
// Test: Can orisha:router be nested inside another orisha:router's catch-all?
// This is the foundation for tree-structured routing where:
// orisha:router(req)
// | [GET /api/health] |> response { ... }
// | [*] |> orisha:router(req) <-- nested router
// | [GET /other] |> response { ... }
// | [*] |> response { ... } <-- inner catch-all
// ============================================================================
~import orisha
~import std/io
const std = @import("std");
const TestRequest = struct {
method: []const u8,
path: []const u8,
};
// Test 1: Hits outer route
const req1 = TestRequest{ .method = "GET", .path = "/api/health" };
~orisha:router(req: &req1)
! [GET /api/health] |> std/io:print.ln("outer: /api/health")
! [*] |> orisha:router(req: &req1)
! [GET /other] |> std/io:print.ln("inner: /other")
! [*] |> std/io:print.ln("inner: catch-all")
// Test 2: Falls through to inner route
const req2 = TestRequest{ .method = "GET", .path = "/other" };
~orisha:router(req: &req2)
! [GET /api/health] |> std/io:print.ln("outer: /api/health")
! [*] |> orisha:router(req: &req2)
! [GET /other] |> std/io:print.ln("inner: /other")
! [*] |> std/io:print.ln("inner: catch-all")
// Test 3: Falls through to inner catch-all
const req3 = TestRequest{ .method = "POST", .path = "/unknown" };
~orisha:router(req: &req3)
! [GET /api/health] |> std/io:print.ln("outer: /api/health")
! [*] |> orisha:router(req: &req3)
! [GET /other] |> std/io:print.ln("inner: /other")
! [*] |> std/io:print.ln("inner: catch-all")
Expected output
outer: /api/health
inner: /other
inner: catch-all
Flows
flow ~router click a branch to expand · @labels scroll to their anchor
router (req: &req1)
flow ~router click a branch to expand · @labels scroll to their anchor
router (req: &req2)
flow ~router click a branch to expand · @labels scroll to their anchor
router (req: &req3)
Test Configuration
MUST_RUN