011 array literal bindings

✓ Passing This code compiles and runs correctly.

Code

// TEST: Array literal with flow bindings
//
// Koru array literals can reference bindings from the flow scope.
// This is essential for collecting results from multiple events.
//
// Expected: Compiles and runs, array contains bound values

const std = @import("std");

~event getValue { id: i32 }
| got { value: i32 }

~proc getValue {
    return .{ .got = .{ .value = id * 10 } };
}

~event sumAll { values: []const i32 }
| total { sum: i32 }

~proc sumAll {
    var sum: i32 = 0;
    for (values) |v| {
        sum += v;
    }
    return .{ .total = .{ .sum = sum } };
}

~event check { expected: i32, actual: i32 }

~proc check {
    if (expected != actual) {
        std.debug.print("FAIL: expected {}, got {}\n", .{ expected, actual });
        std.process.exit(1);
    }
    std.debug.print("PASS: {} == {}\n", .{ expected, actual });
}

// Chain events and collect results in array literal
~getValue(id: 1)
| got a |> getValue(id: 2)
    | got b |> getValue(id: 3)
        | got c |> sumAll(values: [a.value, b.value, c.value])
            | total t |> check(expected: 60, actual: t.sum)
input.kz

Test Configuration

MUST_RUN

Expected Behavior:

CONTAINS PASS: 60 == 60