✓
Passing This code compiles and runs correctly.
Code
// ============================================================================
// Test 207: Label Scope Isolation
// ============================================================================
// Tests that labels with the same name can exist in different flows
// Each flow has its own label namespace - labels are flow-scoped
// This is the POSITIVE counterpart to test 206 (which tests cross-flow errors)
// ============================================================================
const std = @import("std");
// Counter event that can go in both directions
~event count { n: i32, direction: []const u8 }
| next i32
| done i32
~proc count|zig {
std.debug.print("{s}: {}\n", .{direction, n});
if (std.mem.eql(u8, direction, "up")) {
if (n < 3) {
return .{ .next = n + 1 };
} else {
return .{ .done = n };
}
} else {
if (n > 2) {
return .{ .next = n - 1 };
} else {
return .{ .done = n };
}
}
}
// Start events for each flow
~event start-up {}
~event start-down {}
~proc start-up|zig {
std.debug.print("Starting count-up flow...\n", .{});
}
~proc start-down|zig {
std.debug.print("Starting count-down flow...\n", .{});
}
// Flow 1: Count up using label "loop"
// This label is scoped to this flow only
~start-up() |> #loop count(n: 0, direction: "up")
| next c |> @loop(n: c, direction: "up")
| done _ |> _
// Flow 2: Count down using SAME label name "loop"
// This is a DIFFERENT label, scoped to this flow
// Both flows can use the name "loop" without conflict!
~start-down() |> #loop count(n: 5, direction: "down")
| next c |> @loop(n: c, direction: "down")
| done _ |> _
Actual
Starting count-up flow...
up: 0
up: 1
up: 2
up: 3
Starting count-down flow...
down: 5
down: 4
down: 3
down: 2
Expected output
Starting count-up flow...
up: 0
up: 1
up: 2
up: 3
Starting count-down flow...
down: 5
down: 4
down: 3
down: 2
Test Configuration
MUST_RUN