✓
Passing This code compiles and runs correctly.
Code
// Test 110_002: Directory Import WITHOUT Public Markers
//
// Tests that non-public events CANNOT be called from outside their module.
// The events in test_lib/ are NOT marked ~pub, so they should be private.
//
// Structure:
// test_lib/
// graphics.kz -> test_lib.graphics: (NO ~pub markers)
// audio.kz -> test_lib.audio: (NO ~pub markers)
//
// CURRENT STATUS: BUG - This test passes when it should fail.
//
// Expected behavior: SEMANTIC ERROR (not parse error!)
// Koru's parser is intentionally dumb - it doesn't validate visibility.
// The visibility check should happen during event resolution, when we
// verify that a cross-module event reference points to a ~pub event.
//
// TODO: Implement visibility checking in event resolution, then mark
// this test as MUST_FAIL.
//
// See test 110_003 for the SUCCESS case (with ~pub events)
const std = @import("std");
~import app/test_lib
// Initialize graphics subsystem
~app/test_lib/graphics:init()
// Initialize audio subsystem
~app/test_lib/audio:init()
// Render a frame
~app/test_lib/graphics:render(frame: 42)
// Play a sound
~app/test_lib/audio:play(sound: "explosion.wav")
Must fail at frontend compile:
Parsing or type-checking must reject the program.
Expected compiler error
error[KORU044]: cannot access private event 'app.test_lib.graphics:init' from module 'input'
--> tests/regression/100_MODULE_SYSTEM/110_IMPORTS/110_002_directory_import_basic/input.kz:28:0
|
28 | ~app/test_lib/graphics:init()
| ^
hint: mark the event as public with ~pub event
error[KORU044]: cannot access private event 'app.test_lib.audio:init' from module 'input'
--> tests/regression/100_MODULE_SYSTEM/110_IMPORTS/110_002_directory_import_basic/input.kz:31:0
|
31 | ~app/test_lib/audio:init()
| ^
hint: mark the event as public with ~pub event
error[KORU044]: cannot access private event 'app.test_lib.graphics:render' from module 'input'
--> tests/regression/100_MODULE_SYSTEM/110_IMPORTS/110_002_directory_import_basic/input.kz:34:0
|
34 | ~app/test_lib/graphics:render(frame: 42)
| ^
hint: mark the event as public with ~pub event
error[KORU044]: cannot access private event 'app.test_lib.audio:play' from module 'input'
--> tests/regression/100_MODULE_SYSTEM/110_IMPORTS/110_002_directory_import_basic/input.kz:37:0
|
37 | ~app/test_lib/audio:play(sound: "explosion.wav")
| ^
hint: mark the event as public with ~pub event
Imported Files
// Audio module for test_lib
const std = @import("std");
~event init {}
~event play { sound: []const u8 }
~proc init|zig {
std.debug.print("Audio initialized\n", .{});
}
~proc play|zig {
std.debug.print("Playing sound: {s}\n", .{sound});
}
// Graphics module for test_lib
const std = @import("std");
~event init {}
~event render { frame: i32 }
~proc init|zig {
std.debug.print("Graphics initialized\n", .{});
}
~proc render|zig {
std.debug.print("Rendering frame {d}\n", .{frame});
}