✓
Passing This code compiles and runs correctly.
Code
// Test 829: Multi-event chain (realistic composition)
//
// Real programs chain multiple events together with deep nesting.
// This tests that the compiler can handle:
// - 5+ events in a chain
// - 3+ levels of nested continuations
// - Data flowing through multiple stages
// - Error handling at multiple levels
const std = @import("std");
// Stage 1: Parse input
~event parse { input: []const u8 }
| parsed i32
| invalid []const u8
~proc parse {
const value = std.fmt.parseInt(i32, input, 10) catch {
return .{ .@"invalid" = "Not a number" };
};
return .{ .@"parsed" = value };
}
// Stage 2: Validate
~event validate { value: i32 }
| valid i32
| invalid []const u8
~proc validate {
if (value < 0 or value > 100) {
return .{ .@"invalid" = "Out of range" };
}
return .{ .@"valid" = value };
}
// Stage 3: Transform
~event transform { value: i32 }
| transformed i32
~proc transform {
return .{ .@"transformed" = value * 2 };
}
// Stage 4: Format
~event format { value: i32 }
| formatted []const u8
~proc format {
const allocator = std.heap.page_allocator;
const text = std.fmt.allocPrint(allocator, "Result: {}", .{value}) catch {
return .{ .@"formatted" = "Error formatting" };
};
return .{ .@"formatted" = text };
}
// Stage 5: Display
~event display { text: []const u8 }
| done
~proc display {
std.debug.print("{s}\n", .{text});
return .{ .@"done" = .{} };
}
// The chain: parse -> validate -> transform -> format -> display
// With error handling at each stage
~parse(input: "42")
| parsed p |> validate(value: p)
| valid v |> transform(value: v)
| transformed t |> format(value: t)
| formatted f |> display(text: f)
| done |> _
| invalid i |> display(text: i)
| done |> _
| invalid i |> display(text: i)
| done |> _
Test Configuration
Expected Behavior:
STDOUT_CONTAINS:Result: 84