001 module qualified phantom states

✗ Failing This test is currently failing.

Failed: backend-exec

Failure Output

Showing last 10 of 11 lines
  --> phantom_semantic_check:25:0

❌ Compiler coordination error: Phantom semantic validation failed
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_001_module_qualified_phantom_states/backend.zig:10832:17: 0x102dd24af in emit (backend)
                return error.CompilerCoordinationFailed;
                ^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_001_module_qualified_phantom_states/backend.zig:10916:28: 0x102dd32b7 in main (backend)
    const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
                           ^

Code

// ============================================================================
// VERIFIED REGRESSION TEST - DO NOT MODIFY WITHOUT DISCUSSION
// ============================================================================
// Test 507: Module-qualified phantom states
// Tests that semantic phantom checker resolves module-qualified states
// Demonstrates: Cross-module phantom type usage with qualification

~import "$std/io"
~import "$app/fileops"

const std = @import("std");

// Define File type for testing
const File = struct {
    handle: i32,
};

// Use module-qualified phantom states
// The semantic checker should:
// 1. Resolve "app.fileops:open" to canonical module path
// 2. Validate that opened file has correct phantom state
// 3. Accept the file in close() which expects app.fileops:open

~app.fileops:open(path: "test.txt")
| opened f |> app.fileops:close(file: f)  // f: *File[app.fileops:open]
    | closed |> std.io:println(text: "File closed successfully")
input.kz

Expected

Opening file: test.txt
Closing file
File closed successfully

Imported Files

// Library module: fileops
// Defines file operations with phantom type states

const std = @import("std");

// File type with phantom states
const File = struct {
    handle: i32,
};

// Open a file - returns opened state
~pub event open { path: []const u8 }
| opened *File[open]

~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 };
}

// Close a file - accepts open state, returns closed state
~pub event close { file: *File[open] }
| closed

~proc close {
    std.debug.print("Closing file\n", .{});
    return .{ .closed = .{} };
}
fileops.kz

Test Configuration

MUST_RUN