✓
Passing This code compiles and runs correctly.
Code
// Test: Registry Scope - Event Aliasing
//
// Verifies that -> alias syntax in scope registration:
// 1. Aliases dispatch to the correct compiled event
// 2. Same event can have multiple aliases with different costs
// 3. Original event name is NOT exposed (alias replaces)
~import "$std/runtime"
~import "$std/io"
const std = @import("std");
~pub event greet { name: []const u8 }
| greeted { message: []const u8 }
~proc greet {
return .{ .greeted = .{ .message = name } };
}
// Register same event under two aliases
~std.runtime:register(scope: "api") {
greet -> hello(1)
greet -> hi(3)
}
// Test 1: alias "hello" dispatches to greet
const TEST1 = "~hello(name: \"World\")";
~std.runtime:run(source: TEST1, scope: "api")
| result _ |> std.io:print.ln("HELLO OK")
| exhausted _ |> std.io:print.ln("HELLO EXHAUSTED")
| parse_error _ |> std.io:print.ln("HELLO PARSE ERROR")
| validation_error _ |> std.io:print.ln("HELLO VALIDATION ERROR")
| shape_error _ |> std.io:print.ln("HELLO SHAPE ERROR")
| event_denied _ |> std.io:print.ln("HELLO EVENT DENIED")
| dispatch_error _ |> std.io:print.ln("HELLO DISPATCH ERROR")
| scope_not_found _ |> std.io:print.ln("HELLO SCOPE NOT FOUND")
// Test 2: alias "hi" also dispatches to greet (different cost)
const TEST2 = "~hi(name: \"World\")";
~std.runtime:run(source: TEST2, scope: "api")
| result _ |> std.io:print.ln("HI OK")
| exhausted _ |> std.io:print.ln("HI EXHAUSTED")
| parse_error _ |> std.io:print.ln("HI PARSE ERROR")
| validation_error _ |> std.io:print.ln("HI VALIDATION ERROR")
| shape_error _ |> std.io:print.ln("HI SHAPE ERROR")
| event_denied _ |> std.io:print.ln("HI EVENT DENIED")
| dispatch_error _ |> std.io:print.ln("HI DISPATCH ERROR")
| scope_not_found _ |> std.io:print.ln("HI SCOPE NOT FOUND")
// Test 3: original name "greet" should NOT work (alias replaces)
const TEST3 = "~greet(name: \"World\")";
~std.runtime:run(source: TEST3, scope: "api")
| result _ |> std.io:print.ln("GREET SHOULD NOT WORK")
| exhausted _ |> std.io:print.ln("GREET EXHAUSTED")
| parse_error _ |> std.io:print.ln("GREET PARSE ERROR")
| validation_error _ |> std.io:print.ln("GREET VALIDATION ERROR")
| shape_error _ |> std.io:print.ln("GREET SHAPE ERROR")
| event_denied _ |> std.io:print.ln("GREET DENIED OK")
| dispatch_error _ |> std.io:print.ln("GREET DISPATCH ERROR")
| scope_not_found _ |> std.io:print.ln("GREET SCOPE NOT FOUND")
Expected
HELLO OK
HI OK
GREET DENIED OK
Actual
HELLO OK
HI OK
GREET DENIED OK
Test Configuration
MUST_RUN