001 http routing

✓ Passing This code compiles and runs correctly.

Code

// MUST_FAIL: Zig-style struct syntax in parameter values must be rejected
//
// Koru does not support Zig anonymous struct literals (.{ .field = value })
// in flow call parameters. Use named parameters instead.

~import "$std/io"

const std = @import("std");

pub const Request = struct {
    method: []const u8,
    path: []const u8,
};

~pub event handle { req: Request }
| response { status: u16, body: []const u8 }

~proc handle|zig {
    return .{ .response = .{ .status = 200, .body = "ok" } };
}

// WRONG: Zig-style struct literal in parameter value
~handle(req: .{ .method = "GET", .path = "/health" })
| response r |> std.io:print.ln("{{ r.body:s }}")
input.kz

Must fail at frontend compile:

Parsing or type-checking must reject the program.

Expected compiler error

error[PARSE003]: Zig-style struct syntax '.{' is not valid in Koru parameter values — pass fields as named parameters instead
  --> tests/regression/300_ADVANCED_FEATURES/350_PATTERN_BRANCHES/350_001_http_routing/input.kz:23:1
    |
 23 | ~handle(req: .{ .method = "GET", .path = "/health" })
    | ^

Test Configuration

Expected Error:

Zig-style struct syntax