✓
Passing This code compiles and runs correctly.
Code
// Ground truth for korulang.org phantom explorer — commit without exec
//
// EXPECTED: Compiler error — started! cannot commit
~import app/db
~app/db:open(connstr: "postgres://localhost/test")
| connected c |> app/db:tx.begin(conn: c)
| tx t |> app/db:tx.commit(tx: t)
| committed conn |> app/db:close(conn)
| connection-failed |> _
Must contain:
Phantom state mismatchError Verification
Actual Compiler Output
error[KORU030]: Phantom state mismatch: expected 'app.db:active' but got 'app.db:started!' for argument 'tx'
--> phantom_semantic_check:8:0
❌ Compiler coordination error: Phantom semantic validation failed
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/900_EXAMPLES_SHOWCASE/910_LANGUAGE_SHOOTOUT/2104_18_open_tx_empty_commit/backend.zig:94:13: 0x104f563b3 in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/900_EXAMPLES_SHOWCASE/910_LANGUAGE_SHOOTOUT/2104_18_open_tx_empty_commit/backend.zig:190:28: 0x104f5709f in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^Imported Files
// open/tx lifecycle API — ground truth for korulang.org phantom explorer
const std = @import("std");
const Connection = struct { handle: i32 };
const Transaction = struct { conn_handle: i32 };
~pub event open { connstr: []const u8 }
| connected *Connection<connected!>
| connection-failed
~proc open|zig {
_ = connstr;
const c = std.heap.page_allocator.create(Connection) catch unreachable;
c.* = Connection{ .handle = 42 };
return .{ .connected = c };
}
~pub event tx.begin { conn: *Connection<!connected|!active> }
| tx *Transaction<started!>
~proc tx.begin|zig {
const t = std.heap.page_allocator.create(Transaction) catch unreachable;
t.* = Transaction{ .conn_handle = conn.handle };
return .{ .tx = t };
}
~pub event tx.exec { tx: *Transaction<!started|!active>, sql: []const u8 }
| ok *Transaction<active!>
~proc tx.exec|zig {
std.debug.print("Executing: {s}\n", .{sql});
return .{ .ok = tx };
}
~pub event tx.commit { tx: *Transaction<!active> }
| committed *Connection<active!>
~proc tx.commit|zig {
std.debug.print("COMMIT\n", .{});
const c = std.heap.page_allocator.create(Connection) catch unreachable;
c.* = Connection{ .handle = tx.conn_handle };
std.heap.page_allocator.destroy(tx);
return .{ .committed = c };
}
~pub event tx.rollback { tx: *Transaction<!active> }
| rolled-back *Connection<active!>
~proc tx.rollback|zig {
std.debug.print("ROLLBACK\n", .{});
const c = std.heap.page_allocator.create(Connection) catch unreachable;
c.* = Connection{ .handle = tx.conn_handle };
std.heap.page_allocator.destroy(tx);
return .{ .rolled_back = c };
}
~[!]pub event close { conn: *Connection<!active> }
~proc close|zig {
std.debug.print("Connection closed\n", .{});
std.heap.page_allocator.destroy(conn);
}
Test Configuration
MUST_FAIL