○
Planned This feature is planned but not yet implemented.
BUG: Label jump @loop(iteration: iteration + 1) fails — 'iteration' not in scope.
Error Details
output_emitted.zig:72:38: error: use of undeclared identifier 'iteration'
Failure Output
Showing last 10 of 130 lines
[MAIN DEBUG] Before file write:
[MAIN DEBUG] generated_code.len = 13238
[MAIN DEBUG] generated_code.ptr = u8@1097cf988
[MAIN DEBUG] emitted_file = output_emitted.zig
[MAIN DEBUG] emitted_file.ptr = u8@1043df5be
[MAIN DEBUG] First 50 bytes: // Access compiler flags from backend.zig via root
Error: output_emitted.zig:72:38: error: use of undeclared identifier 'iteration'
loop_iteration = iteration + 1;
^~~~~~~~~ Code
// Test 918h: Optional Branches - Event Pump Loop (THE USE CASE)
//
// Verifies:
// 1. Event pump with multiple optional event types
// 2. Loop using labels/jumps that repeatedly calls pump
// 3. |? catches unhandled events, loop continues
// 4. THE motivating use case: wrapping WIN32/SDL/etc event systems
~import "$std/io"
const std = @import("std");
// Simulated event pump - all branches optional (any event can fire)
~event pump { iteration: u32 }
| ?keyboard i32
| ?mouse i32
| ?window i32
| ?timer i32
| ?quit
~proc pump {
const i = iteration;
// After 8 iterations, quit
if (i >= 8) {
return .{ .quit = .{} };
}
// Cycle: keyboard, mouse, window, timer
const event_type = i % 4;
if (event_type == 0) {
return .{ .keyboard = @intCast(i) };
} else if (event_type == 1) {
return .{ .mouse = @intCast(i) };
} else if (event_type == 2) {
return .{ .window = @intCast(i) };
} else {
return .{ .timer = @intCast(i) };
}
}
// Event loop: only handle keyboard and mouse, |? catches the rest
~#loop pump(iteration: 0)
| keyboard _ |> std.io:print.ln("KEYBOARD") |> @loop(iteration: iteration + 1)
| mouse _ |> std.io:print.ln("MOUSE") |> @loop(iteration: iteration + 1)
| quit _ |> std.io:print.ln("QUIT")
|? |> std.io:print.ln("OTHER") |> @loop(iteration: iteration + 1)
Expected
KEYBOARD
MOUSE
OTHER
OTHER
KEYBOARD
MOUSE
OTHER
OTHER
QUIT
Test Configuration
MUST_RUN