✓
Passing This code compiles and runs correctly.
Code
// Test 210_076: optional effect branch (`! ?warning`) at event decl.
// Symmetric with `| ?name` — consumers may omit handlers without
// exhaustiveness error; unhandled calls become no-ops.
~pub event tokenize { source: []const u8 }
! token []const u8
! ?warning []const u8
| done usize
Expected AST
{
"module_annotations": [],
"items": [
{
"type": "import_decl",
"path": "$std/compiler",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_076_optional_effect_branch_decl/input.kz",
"line": 2,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_076_optional_effect_branch_decl/input.kz",
"line": 2,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_076_optional_effect_branch_decl/input.kz",
"line": 3,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_076_optional_effect_branch_decl/input.kz",
"line": 4,
"col": 0
}
},
{
"type": "event_decl",
"name": "tokenize",
"path": [
"tokenize"
],
"module": "input",
"input": {
"fields": [
{
"name": "source",
"type": "[]const u8",
"is_source": false,
"is_file": false,
"is_embed_file": false,
"is_expression": false,
"is_invocation_meta": false,
"phantom": null
}
]
},
"branches": [
{
"name": "token",
"kind": "effect",
"resume": null,
"is_optional": false,
"payload": {
"fields": [
{
"name": "__type_ref",
"type": "[]const u8",
"is_source": false,
"is_file": false,
"is_embed_file": false,
"is_expression": false,
"is_invocation_meta": false,
"phantom": null
}
]
}
},
{
"name": "warning",
"kind": "effect",
"resume": null,
"is_optional": true,
"payload": {
"fields": [
{
"name": "__type_ref",
"type": "[]const u8",
"is_source": false,
"is_file": false,
"is_embed_file": false,
"is_expression": false,
"is_invocation_meta": false,
"phantom": null
}
]
}
},
{
"name": "done",
"kind": "terminal",
"resume": null,
"is_optional": false,
"payload": {
"fields": [
{
"name": "__type_ref",
"type": "usize",
"is_source": false,
"is_file": false,
"is_embed_file": false,
"is_expression": false,
"is_invocation_meta": false,
"phantom": null
}
]
}
}
],
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_076_optional_effect_branch_decl/input.kz",
"line": 10,
"col": 0
}
}
]
}Test Configuration
PARSER_TEST