○
Planned This feature is planned but not yet implemented.
Requires a transform to handle pattern branches.
Failure Output
Showing last 10 of 54 lines
--> structural_check:38:0
❌ Compiler coordination error: Incomplete branch coverage
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/350_PATTERN_BRANCHES/350_003_pattern_dispatch/backend.zig:10994:17: 0x10307e433 in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/350_PATTERN_BRANCHES/350_003_pattern_dispatch/backend.zig:11078:28: 0x10307f1bf in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^ Code
// Test: Pattern branch dispatch
//
// Pattern branches should dispatch based on matching the pattern against
// the event's return value. This test uses actual pattern branch syntax.
//
// The transform should:
// 1. Detect pattern branches (branch name starts with '[')
// 2. Parse the pattern to extract method + path template
// 3. Generate dispatch code that matches against the payload
// 4. Extract path params into the binding
~import "$std/io"
const std = @import("std");
// Request type - the payload we're matching against
pub const Request = struct {
method: []const u8,
path: []const u8,
};
// Params extracted from path
pub const Params = struct {
id: ?[]const u8 = null,
};
// Event that returns a request
~pub event incoming {}
| request Request
~proc incoming {
return .{ .request = .{ .method = "GET", .path = "/users/42" } };
}
// This is what we WANT to work:
// Pattern branches dispatch based on matching method + path
~incoming()
| [GET /users/:id] p |> std.io:print.ln("user id: {{ p.id:s }}")
| [GET /health] _ |> std.io:print.ln("health check")
| [POST /users] _ |> std.io:print.ln("create user")
| [*] _ |> std.io:print.ln("not found")