✗
Failing This test is currently failing.
Failed: wrong-error
Failure Output
Showing last 10 of 11 lines
--> tests/regression/300_ADVANCED_FEATURES/335_OBLIGATION_STRESS/335_007_chain_second_err_leaks_first_resource/input.kz:23:0
❌ Compiler coordination error: Incomplete branch coverage
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/335_OBLIGATION_STRESS/335_007_chain_second_err_leaks_first_resource/backend.zig:94:13: 0x10480e3b3 in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/335_OBLIGATION_STRESS/335_007_chain_second_err_leaks_first_resource/backend.zig:190:28: 0x10480f09f in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^ Code
// PIN: mid-chain error path leaks the connection.
//
// connect() opens *Connection<connected!>. query() READS the connection
// (conn: *Connection<connected> — no consume marker) and can return | err.
// On the | err path, the connection is still alive with connected! obligation
// but the handler drops to _ without calling disconnect().
//
// Legal form (both paths discharge): 330_027_db_transaction_pattern/input.kz:4-8
// Both | then and | else call disconnect(conn: c).
//
// Rust analogy: Acquiring a resource, calling a fallible operation that borrows
// it, and returning early via `?` — the resource is leaked because no RAII
// destructor fires and no manual drop is in scope.
//
// Grounding:
// connect event + connected! obligation: 330_027_db_transaction_pattern/db.kz:20-29
// query reads (non-consuming) connection: 330_027_db_transaction_pattern/db.kz:34-43
// disconnect consumes connected!: 330_027_db_transaction_pattern/db.kz:62-64
// chain structure: 330_027_db_transaction_pattern/input.kz:4-8
// | err _ |> _ branch syntax: 330_061_inline_obligation_cascade/input.kz:81
~import app/db
~app/db:connect(url: "postgres://localhost/test")
| connected c |> app/db:query(conn: c, sql: "SELECT 1")
| started tx |> app/db:rollback(tx) |> app/db:disconnect(conn: c)
| err _ |> _
Must contain:
was not dischargedError Verification
Actual Compiler Output
error[KORU021]: event 'app.db:query' has no branch 'err' (available: started)
--> tests/regression/300_ADVANCED_FEATURES/335_OBLIGATION_STRESS/335_007_chain_second_err_leaks_first_resource/input.kz:23:0
❌ Compiler coordination error: Incomplete branch coverage
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/335_OBLIGATION_STRESS/335_007_chain_second_err_leaks_first_resource/backend.zig:94:13: 0x10480e3b3 in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/335_OBLIGATION_STRESS/335_007_chain_second_err_leaks_first_resource/backend.zig:190:28: 0x10480f09f in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^Imported Files
// Library module: db
// Database operations with layered cleanup obligations
//
// Pattern: connect → query → (commit OR rollback) → disconnect
// Two obligations:
// 1. connected! on Connection - must call disconnect
// 2. transaction! on Transaction - must call commit or rollback
const std = @import("std");
const Connection = struct {
id: i32,
};
const Transaction = struct {
conn: *Connection,
};
// Connect to database - creates connected! obligation
~pub event connect { url: []const u8 }
| connected *Connection<connected!>
~proc connect|zig {
std.debug.print("Connecting to: {s}\n", .{url});
const allocator = std.heap.page_allocator;
const c = allocator.create(Connection) catch unreachable;
c.* = Connection{ .id = 1 };
return .{ .connected = c };
}
// Start a query/transaction - creates transaction! obligation
// The connection must be in [connected] state (required, but not consumed)
// The connected! obligation is tracked separately and discharged by disconnect()
~pub event query { conn: *Connection<connected>, sql: []const u8 }
| started *Transaction<transaction!>
~proc query|zig {
std.debug.print("Query: {s}\n", .{sql});
const allocator = std.heap.page_allocator;
const t = allocator.create(Transaction) catch unreachable;
t.* = Transaction{ .conn = conn };
return .{ .started = t };
}
// Commit - CONSUMES transaction! obligation
~pub event commit { tx: *Transaction<!transaction> }
~proc commit|zig {
std.debug.print("Committing transaction\n", .{});
}
// Rollback - CONSUMES transaction! obligation (alternative to commit)
~pub event rollback { tx: *Transaction<!transaction> }
~proc rollback|zig {
std.debug.print("Rolling back transaction\n", .{});
}
// Disconnect - CONSUMES connected! obligation
~pub event disconnect { conn: *Connection<!connected> }
~proc disconnect|zig {
std.debug.print("Disconnecting\n", .{});
}
Test Configuration
MUST_FAIL