subflow invalid branch

✓ Passing This code compiles and runs correctly.

Code

// ============================================================================
// Test 305: Subflow with Invalid Branch Reference
// ============================================================================
// Tests that the shape checker validates subflow continuations
// A subflow that references a non-existent branch should fail shape checking
// ============================================================================

const std = @import("std");

// Event with only ONE branch
~event double { value: i32 }
| doubled { value: i32 }

~proc double {
    return .{ .doubled = .{ .value = value * 2 } };
}

// Event to test
~event process { input: i32 }
| final { output: i32 }

// INVALID subflow: references 'tripled' branch but double event has no such branch!
// This should fail shape checking with "Event 'double' has no branch 'tripled'"
~process = double(value: input)
| doubled d |> final { output: d.value }
| tripled t |> final { output: t.value }  // ERROR: 'tripled' doesn't exist!
input.kz

Error Verification

Expected Error Pattern

Subflow Invalid Branch Validation Test

This test MUST FAIL to verify that the shape checker validates subflow continuations.

Expected behavior:
- Subflow invokes `double` which only has a `doubled` branch
- Subflow has a continuation for `tripled` which doesn't exist
- Shape checker should reject this with "Event 'double' has no branch 'tripled'"

This validates that the shape checker properly checks subflow continuation branches.

Actual Compiler Output

[PHASE 2.4] Calling run_pass for transforms\n[PHASE 2.5] Executing comptime_main() - running comptime flows
[PHASE 2.5] Comptime flows complete (30 items)
[PHASE 2.6] Rescanning transformed AST (30 items)
[PHASE 2.6] Rescan complete: 25 comptime events found
  [0] std.compiler:requires
  [1] std.compiler:flag.declare
  [2] std.compiler:command.declare
  [3] std.compiler:coordinate
  [4] std.compiler:context_create
  [5] std.testing:test
  [6] std.testing:validate_mocks
  [7] std.testing:test.with_harness
  [8] std.testing:test.harness
  [9] std.testing:assert
  [10] std.testing:test.property.equivalent
  [11] std.deps:deps
  [12] std.deps:requires.system
  [13] std.deps:requires.zig
  [14] std.control:if
  [15] std.control:for
  [16] std.control:capture
  [17] std.control:const
  [18] std.build:requires
  [19] std.build:variants
  [20] std.build:config
  [21] std.build:command.sh
  [22] std.build:command.zig
  [23] std.build:step
  [24] std.template:define
error[KORU021]: continuation references unknown branch 'tripled'
  --> structural_check:28:0

❌ Compiler coordination error: Incomplete branch coverage
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/350_SUBFLOWS/305_subflow_invalid_branch/backend.zig:9389:17: 0x1049d6433 in emit (backend)
                return error.CompilerCoordinationFailed;
                ^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/350_SUBFLOWS/305_subflow_invalid_branch/backend.zig:9473:28: 0x1049d71bf in main (backend)
    const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
                           ^

Test Configuration

MUST_FAIL