030 comptime flows

✗ Failing This test is currently failing.

Failed: frontend

Failure Output

error[KORU010]: '|>' cannot start a line
  --> tests/regression/200_COMPILER_FEATURES/210_PARSER/210_030_comptime_flows/input.kz:52:0
    |
 52 | |> _
    | ^^
  hint: '|>' is inline glue only — it joins a body to its branch handler, or chains void events on one line. Three legal layouts: (1) fold inline `~A() |> B()`; (2) split into separate top-level statements `~A()` then `~B()`; (3) delete the redundant `|> _` if the head suffices.

Code

// Test 111: Comptime Flow Emission
// Tests that [comptime] events are emitted as comptime_flowN() and comptime_main()
// and that they execute during backend compilation

const std = @import("std");

// Test 1: Comptime event that executes during compilation
~[comptime] event validateConventions {}

~proc validateConventions {
    // This code executes at compile time!
    // We can't print, but we can do comptime-safe operations
    const conventions_valid = true;
    _ = conventions_valid;
}

// Test 2: Comptime event with literal string parameter
~[comptime] event bundleAssets {
    dir: []const u8
}
| bundled i32

~proc bundleAssets {
    // Comptime asset bundling - executes during compilation
    const asset_count = dir.len; // Can operate on comptime strings
    _ = asset_count;
    return .{ .bundled = 42 };
}

// Test 3: Comptime event with error branch
~[comptime] event preprocessMipmaps {
    inputDir: []const u8
}
| ok i32
| err []const u8

~proc preprocessMipmaps {
    // Comptime mipmap preprocessing
    const dir_len = inputDir.len;
    _ = dir_len;
    return .{ .ok = 10 };
}

// Top-level comptime flows (execute during backend compilation!)
~[comptime] validateConventions()
| validated |> _

~[comptime] bundleAssets(dir: "assets/textures")
| bundled _ |> _

~[comptime] preprocessMipmaps(inputDir: "assets/images")
|> _
| err _ |> _
input.kz