001 module qualified phantom states

✓ Passing This code compiles and runs correctly.

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.file)  // f.file: *File[app.fileops:open]
    | closed |> std.io:println(text: "File closed successfully")
input.kz

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: *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 = .{ .file = 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