059 reject consume on output

✓ Passing This code compiles and runs correctly.

Code

// TEST: Reject obligation consumption [!state] on output parameters
//
// The ! prefix means "consume obligation" - this only makes sense on INPUT.
// On OUTPUT, you can:
//   - [state]   = produce in this state (no obligation)
//   - [state!]  = issue an obligation that must be discharged
//
// But [!state] on output is semantically invalid - you can't "consume" an
// obligation on something you're producing.
//
// MUST_FAIL: Cannot consume obligation

const Connection = struct { id: i32 };

// INVALID: [!connected] on output tries to consume an obligation
// This should be either [connected] (just state) or [connected!] (issue obligation)
~pub event connect { url: []const u8 }
| ok *Connection[!connected]

~proc connect {
    return .{ .ok = undefined };
}

pub fn main() void {}
input.kz

Error Verification

Expected Error Pattern

Cannot consume obligation

Actual Compiler Output ✓ Pattern matched

error[KORU033]: Cannot consume obligation '[!connected]' on output parameter (event: connect). Use '[connected!]' to issue a new obligation, or remove the '!' prefix.
  --> phantom_semantic_check:20:0

❌ Compiler coordination error: Phantom semantic validation failed
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_059_reject_consume_on_output/backend.zig:9304:17: 0x102cda4af in emit (backend)
                return error.CompilerCoordinationFailed;
                ^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_059_reject_consume_on_output/backend.zig:9388:28: 0x102cdb2b7 in main (backend)
    const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
                           ^

Test Configuration

MUST_FAIL