✓
Passing This code compiles and runs correctly.
Code
// ============================================================================
// TEST: Pattern Branches Parser Support
// ============================================================================
// Verifies that the parser correctly handles [...] pattern branch syntax.
// Pattern branches allow opaque expressions as branch names for DSL transforms.
//
// The [...] content is passed through as the branch name - transforms interpret it.
// ============================================================================
// Simple event to test pattern branches
~event test-patterns {}
~proc test-patterns|zig {
}
// Test that pattern branches parse correctly
// The branch names are [GET /users/:id] etc - opaque to the compiler
~test-patterns()
| [GET /users/:id] => ok {}
| [POST /users] => ok {}
| [nested [brackets] work] => ok {}
| [* -> stopped] => ok {} // State machine style
// Verify nested patterns work
~test-patterns()
| [/admin/*] |> test-patterns()
| [GET /dashboard] => ok {}
Must contain:
no branch 'GET /users/:id'Error Verification
Expected Error Pattern
Pattern branches without a transform produce KORU021 errors.
This test verifies that pattern branch SYNTAX parses correctly.
The validation correctly rejects unknown branches like [GET /users/:id]
when the event only declares 'ok'.
Expected errors:
- KORU021: unknown branch '[GET /users/:id]'
- KORU021: unknown branch '[POST /users]'
- etc.Actual Compiler Output
error[KORU021]: event 'input:test-patterns' has no branch 'GET /users/:id' (available: (none))
--> tests/regression/200_COMPILER_FEATURES/210_PARSER/210_052_pattern_branches/input.kz:19:0
error[KORU021]: event 'input:test-patterns' has no branch 'POST /users' (available: (none))
--> tests/regression/200_COMPILER_FEATURES/210_PARSER/210_052_pattern_branches/input.kz:19:0
error[KORU021]: event 'input:test-patterns' has no branch 'nested [brackets] work' (available: (none))
--> tests/regression/200_COMPILER_FEATURES/210_PARSER/210_052_pattern_branches/input.kz:19:0
error[KORU021]: event 'input:test-patterns' has no branch '* -> stopped' (available: (none))
--> tests/regression/200_COMPILER_FEATURES/210_PARSER/210_052_pattern_branches/input.kz:19:0
❌ Compiler coordination error: Incomplete branch coverage
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/200_COMPILER_FEATURES/210_PARSER/210_052_pattern_branches/backend.zig:94:13: 0x10244b38b in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/200_COMPILER_FEATURES/210_PARSER/210_052_pattern_branches/backend.zig:190:28: 0x10244c077 in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^Test Configuration
MUST_FAIL