✓
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 19 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] other
[TEST] [10] other
[TEST] [11] event_decl
[TEST] [12] proc_decl
[TEST] [13] other
[TEST] [14] other
[TEST] [15] event_decl
[TEST] [16] proc_decl
[TEST] [17] other
[TEST] [18] other
[TEST] Found 1 transformed flows
[TEST] Purity walk complete, 2 impure events
thread 11694001 panic: Test 'Impure events should error' has impure events without mocks: fetch-user, save-log
???:?:?: 0x102b4088f in _backend_output_emitted.koru_std.koru_testing.test_event.handler (???)
???:?:?: 0x102945907 in _backend_output_emitted.call_handler_testing_test (???)
???:?:?: 0x102b4c727 in _transform_pass_runner.applyTransform (???)
???:?:?: 0x102943813 in _transform_pass_runner.walkNode (???)
???:?:?: 0x102943177 in _transform_pass_runner.walkNode (???)
???:?:?: 0x102943177 in _transform_pass_runner.walkNode (???)
???:?:?: 0x102943177 in _transform_pass_runner.walkNode (???)
???:?:?: 0x102943177 in _transform_pass_runner.walkNode (???)
???:?:?: 0x102943177 in _transform_pass_runner.walkNode (???)
???:?:?: 0x1029429b3 in _transform_pass_runner.walkOnce (???)
???:?:?: 0x102944afb in _transform_pass_runner.walkAndTransformStages (???)
???:?:?: 0x1029450b3 in _backend_output_emitted.run_pass (???)
???:?:?: 0x10291b28f in _backend_output_emitted.koru_std.koru_compiler.evaluate_comptime_event.handler (???)
???:?:?: 0x102916e2f in _backend_output_emitted.koru_std.koru_compiler.elaborate_event.handler (???)
???:?:?: 0x102916357 in _backend_output_emitted.koru_std.koru_compiler.coordinate_event.handler (???)
???:?:?: 0x1029161a3 in _koru_coordinate (???)
???:?:?: 0x1028a6603 in _backend.RuntimeEmitter.emit (???)
???:?:?: 0x1028a7937 in _backend.main (???)
???:?:?: 0x1028a9a5b in _main (???)
???:?:?: 0x18073fdff in ??? (???)
???:?:?: 0x0 in ??? (???)
/Users/larsde/src/koru/scripts/regression_lib.sh: line 559: 23917 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