002 phantom transition

✗ Failing This test is currently failing.

Failed: backend-exec

Failure Output

Showing last 10 of 47 lines
                                                                                ^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/350_AUTO_PROC/350_002_phantom_transition/backend.zig:9520:51: 0x102e67077 in main (backend)
    const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
                                                  ^
/opt/homebrew/Cellar/zig/0.15.2_1/lib/zig/std/start.zig:627:37: 0x102e6e64b in main (backend)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x19815dd53 in ??? (???)
???:?:?: 0x0 in ??? (???)
/Users/larsde/src/koru/scripts/regression_lib.sh: line 33: 87748 Abort trap: 6           ./backend output

Code

// TEST: Auto-synthesized proc for phantom state transitions
//
// The core use case: state transitions where only the phantom type changes.
// The proc just passes through the pointer - zero runtime cost.

const std = @import("std");

const Resource = struct { value: i32 };

// Create resource - has a proc (does real work)
~pub event create { value: i32 }
| created *Resource[state_a!]

~proc create {
    const r = std.heap.page_allocator.create(Resource) catch unreachable;
    r.* = Resource{ .value = value };
    return .{ .created = r };
}

// Transition from state_a to state_b - NO PROC NEEDED
// Input and output have same shape (r: *Resource), just different phantom
// Compiler should synthesize: return .{ .transitioned = r };
~pub event transition { r: *Resource[!state_a] }
| transitioned *Resource[state_b!]

// Cleanup state_b - has a proc (does real work)
~pub event cleanup { r: *Resource[!state_b] }

~proc cleanup {
    std.debug.print("cleaned up resource with value {d}\n", .{r.value});
    std.heap.page_allocator.destroy(r);
}

// Test it
~create(value: 99)
| created c |> transition(r: c.r)
    | transitioned t |> cleanup(r: t.r)
input.kz

Test Configuration

Expected Behavior:

cleaned up resource with value 99