✗
Failing This test is currently failing.
Failed: backend-exec
Failure Output
Showing last 10 of 11 lines
--> auto_discharge:9:0
❌ Compiler coordination error: Auto-discharge failed (multiple disposal options or no disposal event)
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_051_union_with_consume_marker/backend.zig:9546:17: 0x10209e4af in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_051_union_with_consume_marker/backend.zig:9630:28: 0x10209f2b7 in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^ Code
// Test 330_051: Union with consume marker
// Tests that !opened|closing discharges obligation from either state
// Demonstrates: consume marker (!) applies to entire union
~import "$app/handle"
// Test 1: finalize() from opened state - discharges obligation
~app.handle:open()
| opened h1 |> app.handle:finalize(h: h1.h)
| done |> _
// Test 2: finalize() from closing state - also discharges obligation
~app.handle:open()
| opened h1 |> app.handle:start_close(h: h1.h)
| closing h2 |> app.handle:finalize(h: h2.h)
| done |> _
Expected
Opening handle
Finalizing handle: 42
Opening handle
Starting close: 42
Finalizing handle: 42
Imported Files
// Library module: handle
// Demonstrates phantom state unions - events that accept multiple states
const std = @import("std");
// Handle type with phantom states
const Handle = struct {
id: i32,
};
// Open a handle - produces obligation (must be finalized)
~pub event open {}
| opened *Handle[opened!]
~proc open {
std.debug.print("Opening handle\n", .{});
const allocator = std.heap.page_allocator;
const h = allocator.create(Handle) catch unreachable;
h.* = Handle{ .id = 42 };
return .{ .opened = h };
}
// Start closing - explicitly discharges opened! and produces closing! obligation
~pub event start_close { h: *Handle[!opened] }
| closing *Handle[closing!]
~proc start_close {
std.debug.print("Starting close: {d}\n", .{h.id});
return .{ .closing = h };
}
// Finalize - accepts EITHER opened OR closing, discharging whichever obligation exists
~pub event finalize { h: *Handle[!opened|closing] }
| done
~proc finalize {
std.debug.print("Finalizing handle: {d}\n", .{h.id});
// Clean up the handle
return .{ .done = .{} };
}
Test Configuration
MUST_RUN