✓
Passing This code compiles and runs correctly.
Code
// Test 518: Obligation lost at boundary
// Tests that obligations cannot disappear at flow boundaries
//
// Key points:
// - bad_subflow internally opens a file (*File[opened!])
// - bad_subflow returns 'done {}' with NO [!] in signature
// - This loses track of the obligation
// - ERROR: Obligation must either be cleaned OR returned with [!]
~import "$app/bad_subflow"
~app.bad_subflow:bad_subflow()
| done |> _
Error Verification
Expected Error Pattern
This test must fail because bad_subflow opens a file with cleanup obligation
but returns without documenting the obligation in its return signature.
The obligation is lost at the flow boundary.Actual Compiler Output
error[KORU030]: branch 'done' has payload but no binding
--> structural_check:13:0
❌ Compiler coordination error: Incomplete branch coverage
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/518_obligation_lost_at_boundary/backend.zig:9391:17: 0x1048d64af in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/518_obligation_lost_at_boundary/backend.zig:9475:28: 0x1048d72b7 in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^Imported Files
~import "$app/fs"
// BAD: Opens file but doesn't document obligation in signature
~pub event bad_subflow {}
| done // NO [!] in signature - obligation disappears!
~proc bad_subflow {
~app.fs:open(path: "data.txt")
| opened f |> done {}
// ERROR: f.file has [opened!] obligation
// but 'done' branch has no [!] in signature
// Obligation is lost!
}
const std = @import("std");
const File = struct { handle: i32 };
~pub event open { path: []const u8 }
| opened *File[opened!]
~proc open {
std.debug.print("Opening file: {s}\n", .{path});
const allocator = std.heap.page_allocator;
const f = allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return .{ .opened = f };
}
Test Configuration
MUST_FAIL