020 nested branch shadowing

✗ Failing This test is currently failing.

Failed: backend-exec

Failure Output

Showing last 10 of 23 lines
  --> tests/regression/200_COMPILER_FEATURES/220_COMPILATION/220_020_nested_branch_shadowing/input.kz:48:0

❌ Compiler coordination error: Incomplete branch coverage
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/200_COMPILER_FEATURES/220_COMPILATION/220_020_nested_branch_shadowing/backend.zig:9668:17: 0x1021c64af in emit (backend)
                return error.CompilerCoordinationFailed;
                ^
/Users/larsde/src/koru/tests/regression/200_COMPILER_FEATURES/220_COMPILATION/220_020_nested_branch_shadowing/backend.zig:9752:28: 0x1021c72b7 in main (backend)
    const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
                           ^

Code

// FIXED: Nested same-branch name no longer causes Zig shadowing error
//
// Previously: When the same branch name (e.g., `done`) appeared at multiple nesting
// levels, the emitter generated captures even when they weren't used.
//
// Fix: Now only captures bindings that are actually referenced in the code.

~import "$std/control"

const std = @import("std");

const Resource = struct {
    id: usize,
    data: [64]u8,
};

~event create { id: usize }
| created *Resource[active!]

~proc create {
    const r = std.heap.page_allocator.create(Resource) catch unreachable;
    r.* = Resource{ .id = id, .data = undefined };
    return .{ .created = r };
}

~event work { r: *Resource[active] }

~proc work {
    r.data[0] +%= 1;
}

~event destroy { r: *Resource[!active] }

~proc destroy {
    std.heap.page_allocator.destroy(r);
}

~event run_one { id: usize }

~run_one = create(id: id)
| created r |> work(r: r)
    | done |> work(r: r)
        | done |> work(r: r)
            | done |> work(r: r)
                | done |> work(r: r)
                    | done |> destroy(r: r) |> finished

~for(0..10)
| each _ |> run_one(id: 0)
    | finished |> _
| done |> _

pub fn main() void {}
input.kz

Test Configuration

MUST_RUN