✓
Passing This code compiles and runs correctly.
Code
// Test 164: Cross-Module Type Reference (Nested Modules)
//
// Tests referencing a type from an explicitly imported nested module.
// Module imports must be explicit - importing a directory does NOT
// automatically load subdirectories.
//
// Structure:
// test_lib/
// domain/
// user.kz -> defines DomainUser struct
//
// Key Test: Explicit import of nested module, then use its types/events.
const std = @import("std");
// Must explicitly import the nested module (using 'domain' alias from koru.json)
~import domain/user
// This event uses a type from an explicitly imported nested module
~pub tor grant-access {
user_data: domain/user:DomainUser,
} -> bool
~proc grant-access|zig {
std.debug.print("Granting access: {s} as {s} (perms: {d})\n",
.{user_data.email, user_data.role, user_data.permissions});
return true;
}
// Create a domain user and grant access
~domain/user:create(email: "admin@example.com", role: "administrator", permissions: 999): c |> grant-access(user_data: c): _
Actual
Granting access: admin@example.com as administrator (perms: 999)
Expected output
Granting access: admin@example.com as administrator (perms: 999)
Flows
flow ~create click a branch to expand · @labels scroll to their anchor
create (email: "admin@example.com", role: "administrator", permissions: 999)
Imported Files
// Nested domain user module
const std = @import("std");
// Define a domain-specific user type
pub const DomainUser = struct {
email: []const u8,
role: []const u8,
permissions: u32,
};
// Event that creates a domain user
~pub tor create {
email: string,
role: string,
permissions: u32,
} -> DomainUser
~proc create|zig {
const new_user = DomainUser{
.email = email,
.role = role,
.permissions = permissions,
};
return new_user;
}
Test Configuration
MUST_RUN