✓
Passing This code compiles and runs correctly.
Code
// FIXED: Void event chaining now generates valid Zig sequential calls
//
// Previously: When chaining void events (work |> work |> destroy), the emitter
// generated `switch (nested_result_0) { . => || { ... } }` which was invalid:
// 1. Void types cannot be switched on
// 2. `. => ||` is invalid syntax
//
// Fix: emitSubflowContinuationsWithDepth now detects void continuations
// (empty branch name) and emits sequential calls without switch.
~import std/control
const std = @import("std");
const Resource = struct { id: usize };
~event create {}
| created *Resource<active!>
~proc create|zig {
const r = std.heap.page_allocator.create(Resource) catch unreachable;
r.* = Resource{ .id = 42 };
return .{ .created = r };
}
~event work { r: *Resource<active> }
~proc work|zig {
std.debug.print("Work\n", .{});
}
~event destroy { r: *Resource<!active> }
~proc destroy|zig {
std.heap.page_allocator.destroy(r);
}
~event run-one {}
~run-one = create()
| created r |> work(r) |> work(r) |> destroy(r)
~for(0..10)
! each _ |> run-one()
| done |> _
Actual
Work
Work
Work
Work
Work
Work
Work
Work
Work
Work
Work
Work
Work
Work
Work
Work
Work
Work
Work
Work
Test Configuration
MUST_RUN