✓
Passing This code compiles and runs correctly.
Code
// Test 210_125: panic branch (`| ?!oom`) at event decl.
//
// A THIRD branch kind alongside required (`|`) and optional (`| ?`):
// required `|` — omit handler => compile error (you must decide)
// optional `| ?` — omit handler => synthesized no-op (safe to ignore)
// panic `| ?!` — omit handler => synthesized @panic(...) (UNSAFE to
// ignore; the path must not silently proceed)
//
// It is the typed, branch-shaped form of "assert, don't fall back / let it
// fail loudly": the failure is visible in the type, recovery is opt-in,
// ignoring it is loud. First customer: std/list:new OOM.
//
// This test pins ONLY the parse: a decl with a panic branch produces an AST
// branch whose `is_panic` is true (and `is_optional` is false). Symmetric
// with 210_076 (optional effect branch decl) which pins `is_optional`.
~pub event alloc { n: usize }
| success []u8
| ?!oom usize
Expected AST
{
"module_annotations": [],
"items": [
{
"type": "import_decl",
"path": "std/compiler",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 2,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 2,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 3,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 4,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 5,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 6,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 7,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 8,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 9,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 10,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 11,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 12,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 13,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 14,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 15,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_125_panic_branch_decl/input.kz",
"line": 16,
"col": 0
}
},
{
"type": "event_decl",
"name": "alloc",
"path": [
"alloc"
],
"module": "input",
"input": {
"fields": [
{
"name": "n",
"type": "usize",
"is_source": false,
"is_file": false,
"is_embed_file": false,
"is_expression": false,
"is_invocation_meta": false,
"phantom": null
}
]
},
"branches": [
{
"name": "success",
"kind": "terminal",
"resume": null,
"resume_phantom": null,
"is_optional": false,
"is_panic": false,
"payload": {
"fields": [
{
"name": "__type_ref",
"type": "[]u8",
"is_source": false,
"is_file": false,
"is_embed_file": false,
"is_expression": false,
"is_invocation_meta": false,
"phantom": null
}
]
}
},
{
"name": "oom",
"kind": "terminal",
"resume": null,
"resume_phantom": null,
"is_optional": false,
"is_panic": true,
"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_125_panic_branch_decl/input.kz",
"line": 21,
"col": 0
}
}
]
}Test Configuration
PARSER_TEST