✓
Passing Passing: the compiler rejects this program as expected.
Code
// Test: Impure events require overrides
// MUST_ERROR: has impure events without overrides
//
// When a test calls an impure event (Zig proc without [pure]),
// the compiler should error and list ALL impure events at once.
//
// This is the "fix/recompile loop killer" - great UX!
~import std/testing
// Impure event - Zig proc without [pure]
~tor fetch-user { id: u32 } -> string
~proc fetch-user|zig {
// This is impure - does I/O (simulated)
return "Alice";
}
// Another impure event
~tor save-log { message: string }
~proc save-log|zig {
// This is impure - writes to disk
}
// Test: Should FAIL - calls impure events without overrides
~test(Impure events should error) {
~fetch-user(id: 1): u |> save-log(message: u.name)
| saved |> assert.ok()
}
Actual compiler output
[TEST] Building mock lookup map
[TEST] Transformed program has 15 items:
[TEST] [0] flow
[TEST] invocation: fetch-user
[TEST] [1] other
[TEST] [2] other
[TEST] [3] other
[TEST] [4] other
[TEST] [5] other
[TEST] [6] other
[TEST] [7] other
[TEST] [8] other
[TEST] [9] event_decl
[TEST] [10] proc_decl
[TEST] [11] other
[TEST] [12] event_decl
[TEST] [13] proc_decl
[TEST] [14] other
[TEST] Found 1 transformed flows
[TEST] Purity walk complete, 2 impure events
thread 101942524 panic: Test 'Impure events should error' has impure events without mocks: fetch-user, save-log
???:?:?: 0x100f02d43 in _backend_output_emitted.koru_std.koru_testing.test_event.handler (???)
???:?:?: 0x100cc4093 in _backend_output_emitted.call_handler_testing_test (???)
???:?:?: 0x100f0dae7 in _transform_pass_runner.applyTransform (???)
???:?:?: 0x100cc24c7 in _transform_pass_runner.walkNode (???)
???:?:?: 0x100cc1fb3 in _transform_pass_runner.walkNode (???)
???:?:?: 0x100cc1fb3 in _transform_pass_runner.walkNode (???)
???:?:?: 0x100cc1fb3 in _transform_pass_runner.walkNode (???)
???:?:?: 0x100cc1fb3 in _transform_pass_runner.walkNode (???)
???:?:?: 0x100cc1fb3 in _transform_pass_runner.walkNode (???)
???:?:?: 0x100cc1b53 in _transform_pass_runner.walkOnce (???)
???:?:?: 0x100cc3507 in _transform_pass_runner.walkAndTransformStages (???)
???:?:?: 0x100cc3883 in _backend_output_emitted.run_pass (???)
???:?:?: 0x100cb2293 in _backend_output_emitted.koru_std.koru_compiler.evaluate_comptime_event.handler (???)
???:?:?: 0x100cadb93 in _backend_output_emitted.koru_std.koru_compiler.elaborate_event.handler (???)
???:?:?: 0x100cad0f3 in _backend_output_emitted.koru_std.koru_compiler.coordinate_event.handler (???)
???:?:?: 0x100cacf33 in _koru_coordinate (???)
???:?:?: 0x100c313fb in _backend.RuntimeEmitter.emit (???)
???:?:?: 0x100c32ebb in _backend.main (???)
???:?:?: 0x100c3af97 in _main (???)
???:?:?: 0x1816a3dff in ??? (???)
???:?:?: 0x0 in ??? (???)
/Users/larsde/src/koru/scripts/regression_lib.sh: line 397: 33593 Abort trap: 6 ./backend outputError output must contain
Test 'Impure events should error' has impure events without mocks: fetch-user, save-logFlows
flow ~test click a branch to expand · @labels scroll to their anchor
test (Impure events should error, source: ~fetch-user(id: 1): u |> save-log(message: u.name)
| saved |> assert.ok())
Test Configuration
MUST_ERROR COMPILE_ONLY