✓
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 120867107 panic: Test 'Impure events should error' has impure events without mocks: fetch-user, save-log
???:?:?: 0x102497633 in _backend_output_emitted.koru_std.koru_testing.test_event.handler (???)
???:?:?: 0x102251ee7 in _backend_output_emitted.call_handler_testing_test (???)
???:?:?: 0x1024a23d7 in _transform_pass_runner.applyTransform (???)
???:?:?: 0x10225031b in _transform_pass_runner.walkNode (???)
???:?:?: 0x10224fe07 in _transform_pass_runner.walkNode (???)
???:?:?: 0x10224fe07 in _transform_pass_runner.walkNode (???)
???:?:?: 0x10224fe07 in _transform_pass_runner.walkNode (???)
???:?:?: 0x10224fe07 in _transform_pass_runner.walkNode (???)
???:?:?: 0x10224fe07 in _transform_pass_runner.walkNode (???)
???:?:?: 0x10224f9a7 in _transform_pass_runner.walkOnce (???)
???:?:?: 0x10225135b in _transform_pass_runner.walkAndTransformStages (???)
???:?:?: 0x1022516d7 in _backend_output_emitted.run_pass (???)
???:?:?: 0x1022400cb in _backend_output_emitted.koru_std.koru_compiler.evaluate_comptime_event.handler (???)
???:?:?: 0x10223b9fb in _backend_output_emitted.koru_std.koru_compiler.elaborate_event.handler (???)
???:?:?: 0x10223af5b in _backend_output_emitted.koru_std.koru_compiler.coordinate_event.handler (???)
???:?:?: 0x10223ad9b in _koru_coordinate (???)
???:?:?: 0x1021bd3fb in _backend.RuntimeEmitter.emit (???)
???:?:?: 0x1021beebb in _backend.main (???)
???:?:?: 0x1021c6f97 in _main (???)
???:?:?: 0x1816a3dff in ??? (???)
???:?:?: 0x0 in ??? (???)
/Users/larsde/src/koru/scripts/regression_lib.sh: line 397: 37166 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