012 optional parent

✓ 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 |> _
input.kz

Error Verification

Expected Error Pattern

This test demonstrates the import depth limit enforcement.

Import paths are limited to maximum 2 segments after the alias:
  ✅ ~import "$alias"
  ✅ ~import "$alias/module"
  ✅ ~import "$alias/module/submodule"
  ❌ ~import "$alias/a/b/c"  (TOO DEEP!)

The error message suggests extracting deeply nested paths as their own aliases in koru.json.

Expected error: PARSE003 - import path too deep

Actual Compiler Output

error[PARSE003]: import path too deep: '$app/test_lib/net/tcp' has 3 segments after alias (max: 2)
  To fix: add a new alias to koru.json, e.g.:
    "paths": { "mylib": "./path/to/lib" }
  Then use: ~import "$mylib/..." (Suggested: extract 'app' as its own alias)
  --> tests/regression/100_MODULE_SYSTEM/110_IMPORTS/110_012_optional_parent/input.kz:19:1
    |
 19 | ~import "$app/test_lib/net/tcp"
    | ^

error[PARSE001]: Zig code not allowed in flows. Flows are pure plumbing - use events for computation.
  --> tests/regression/100_MODULE_SYSTEM/110_IMPORTS/110_012_optional_parent/input.kz:31:0
    |
 31 | | connected |> std.debug.print("TCP connected!\n", .{})
    | ^

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_lib/net/tcp.kz

Test Configuration

MUST_FAIL

Expected Behavior:

FRONTEND_COMPILE_ERROR