✓
Passing Passing: the compiler rejects this program as expected.
Code
// ============================================================================
// VERIFIED REGRESSION TEST - DO NOT MODIFY WITHOUT DISCUSSION
// ============================================================================
// Test 206: Label scope errors
// Tests that labels are flow-scoped and cannot be accessed across flows
// Expected to fail compilation with "Unknown label 'loop'" error
// ============================================================================
const std = @import("std");
// Simple counter event
~tor counter { n: i32 }
| next i32
| done i32
~proc counter|zig {
std.debug.print("Count: {}\n", .{n});
if (n < 3) {
return .{ .next = n + 1 };
} else {
return .{ .done = n };
}
}
// Start event
~tor start {}
~proc start|zig {
std.debug.print("Starting...\n", .{});
}
// Flow 1 with a label
~start() |> #loop counter(n: 1)
| next c |> @loop(n: c.value)
| done |> _
// Flow 2 trying to jump to Flow 1's label (should error!)
~start() |> @loop(n: 1) // ERROR: 'loop' is not in scope here
Actual compiler output
error[KORU041]: unknown label '@loop'
--> tests/regression/000_CORE_LANGUAGE/040_CONTROL_FLOW/206_label_scope_errors/input.kz:39:0
❌ Compiler coordination error: Unknown label referenced
(set KORU_BACKEND_TRACE=1 for the backend return trace)Must contain:
unknown labelFlows
flow ~start click a branch to expand · @labels scroll to their anchor
start
flow ~start click a branch to expand · @labels scroll to their anchor
start
Test Configuration
MUST_ERROR