✓
Passing This code compiles and runs correctly.
Code
// Test 167: Import Depth Limit Enforcement (MUST_FAIL)
//
// Tests that import paths are limited to 2 segments after the alias.
// This enforces good architectural design by forcing extraction of
// deeply nested paths into their own koru.json aliases.
//
// Maximum allowed depth:
// ✅ ~import "$app" (0 segments)
// ✅ ~import "$app/module" (1 segment)
// ✅ ~import "$app/module/sub" (2 segments)
// ❌ ~import "$app/a/b/c" (3 segments - TOO DEEP!)
//
// Expected: PARSE003 error with helpful message about extracting to koru.json
const std = @import("std");
// This import has 3 segments after $app and should FAIL
~import "$app/test_lib/net/tcp"
~event test {}
| done {}
~proc test {
std.debug.print("Test: optional parent\n", .{});
return .{ .done = .{} };
}
// Use submodule (no parent exists, that's OK!)
~app.test_lib.net.tcp:connect(host: "localhost", port: 8080)
| connected |> std.debug.print("TCP connected!\n", .{})
| failed |> std.debug.print("TCP failed\n", .{})
// Run test
~test()
| done |> _
Imported Files
// TCP module for test_lib.net
// Note: No parent net.kz file exists - this tests that parent is optional
const std = @import("std");
~pub event connect { host: []const u8, port: u16 }
| connected {}
| failed {}
~proc connect {
std.debug.print("Attempting TCP connection to {s}:{d}\n", .{host, port});
// Simulate connection failure for test
return .{ .failed = .{} };
}
Test Configuration
MUST_FAIL
Expected Behavior:
FRONTEND_COMPILE_ERROR