✓
Passing This code compiles and runs correctly.
Code
// ============================================================================
// VERIFIED REGRESSION TEST - DO NOT MODIFY WITHOUT DISCUSSION
// ============================================================================
// Test 207: Arbitrary label jumps across nested scopes
// Tests that labels support jumping from inner scopes back to outer scopes
// ============================================================================
const std = @import("std");
// Outer loop event
~event outer { x: i32, max: i32 }
| next-outer { x: i32, max: i32 }
| done-outer
~proc outer|zig {
if (x > max) {
return .{ .done_outer = .{} };
}
std.debug.print("Outer: x={}\n", .{x});
return .{ .next_outer = .{ .x = x, .max = max } };
}
// Inner loop event
~event inner { x: i32, y: i32, max: i32 }
| next-inner { x: i32, y: i32, max: i32 }
| done-inner i32
~proc inner|zig {
if (y > max) {
return .{ .done_inner = x };
}
std.debug.print(" Inner: x={}, y={}\n", .{x, y});
return .{ .next_inner = .{ .x = x, .y = y, .max = max } };
}
// Start event
~event start { }
~proc start|zig {
std.debug.print("Starting nested loops...\n", .{});
}
// Flow with nested labels - tests arbitrary jumps!
~start() |> #outer_loop outer(x: 1, max: 3)
| next-outer o |> #inner_loop inner(o.x, y: 1, max: 2)
| next-inner i |> @inner_loop(i.x, y: i.y + 1, i.max) // Loop within inner
| done-inner d |> @outer_loop(x: d + 1, o.max) // Jump back to outer!
| done-outer |> _
Actual
Starting nested loops...
Outer: x=1
Inner: x=1, y=1
Inner: x=1, y=2
Outer: x=2
Inner: x=2, y=1
Inner: x=2, y=2
Outer: x=3
Inner: x=3, y=1
Inner: x=3, y=2
Expected output
Starting nested loops...
Outer: x=1
Inner: x=1, y=1
Inner: x=1, y=2
Outer: x=2
Inner: x=2, y=1
Inner: x=2, y=2
Outer: x=3
Inner: x=3, y=1
Inner: x=3, y=2
Test Configuration
MUST_RUN