✓
Passing This code compiles and runs correctly.
Code
// BUG: Emitter generates duplicate variable names in nested scopes
//
// ISSUE: When multiple events are called at different nesting levels,
// the emitter reuses names like `result_2`, causing Zig compilation errors:
// "error: redeclaration of local constant 'result_2'"
//
// EXPECTED: Each event call should get a unique variable name,
// even across different scopes (loops, branches, etc.)
//
// MINIMAL REPRODUCTION: Two void events followed by a branched event,
// called at different nesting levels.
const std = @import("std");
~import std/control
// Void event (no branches)
~event step-one {}
~proc step-one|zig {
// Does nothing, just tests void event handling
}
// Another void event
~event step-two {}
~proc step-two|zig {
// Does nothing
}
// Event with a result branch
~event get-value {}
| value i32
~proc get-value|zig {
return .{ .value = 42 };
}
// Event to print
~event print-value { v: i32 }
~proc print-value|zig {
std.debug.print("{d}\n", .{v});
}
// Main flow - triggers the naming collision
// The structure: void event -> branched event -> loop -> void event -> branched event
// Both branched events generate `result_N` with same N
~step-one()
~get-value()
| value v1 |> print-value(v: v1) |> for(0..2)
! each _ |> step-two() |> get-value()
| value v2 |> print-value(v: v2)
Actual
42
42
42
Test Configuration
MUST_RUN