077 effect catchall dispatch

✗ Failing This test is currently failing.

Failed: ast-mismatch

Code

// Test 210_077: `!?` catch-all in consumer dispatch (metatype-bound,
// engaging form). Per the pay-for-nothing rule (see EFFECT_BRANCHES.md),
// bare `!? |> _` is rejected — catch-all must engage. The optional
// `?warning` branch is already silently ignorable without any marker
// at the dispatch site; the metatype-bound catch-all here demonstrates
// the reflective-observer shape, where the consumer pays the runtime
// cost in exchange for tier-1 reflection on which branch fired.

~pub event tokenize { source: []const u8 }
! token []const u8
! ?warning []const u8
| done usize

~pub event consume_token { t: []const u8 }
~pub event end_run { n: usize }
~pub event log_unhandled { name: []const u8 }

~tokenize(source: "x")
! token t |> consume_token(t: t)
!? Transition _ |> log_unhandled(name: "warn")
| done n |> end_run(n: n)
input.kz

Output must match:

FRONTEND_OK

Expected AST

{
  "module_annotations": [],
  "items": [
    {
      "type": "import_decl",
      "path": "$std/compiler",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_077_effect_catchall_dispatch/input.kz",
        "line": 2,
        "col": 0
      }
    },
    {
      "type": "host_line",
      "module": "input",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_077_effect_catchall_dispatch/input.kz",
        "line": 2,
        "col": 0
      }
    },
    {
      "type": "host_line",
      "module": "input",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_077_effect_catchall_dispatch/input.kz",
        "line": 3,
        "col": 0
      }
    },
    {
      "type": "host_line",
      "module": "input",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_077_effect_catchall_dispatch/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_077_effect_catchall_dispatch/input.kz",
        "line": 10,
        "col": 0
      }
    },
    {
      "type": "event_decl",
      "name": "consume_token",
      "path": [
        "consume_token"
      ],
      "module": "input",
      "input": {
        "fields": [
          {
            "name": "t",
            "type": "[]const u8",
            "is_source": false,
            "is_file": false,
            "is_embed_file": false,
            "is_expression": false,
            "is_invocation_meta": false,
            "phantom": null
          }
        ]
      },
      "branches": [],
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_077_effect_catchall_dispatch/input.kz",
        "line": 12,
        "col": 0
      }
    },
    {
      "type": "event_decl",
      "name": "end_run",
      "path": [
        "end_run"
      ],
      "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": [],
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_077_effect_catchall_dispatch/input.kz",
        "line": 13,
        "col": 0
      }
    },
    {
      "type": "flow",
      "invocation": {
        "event": [
          "tokenize"
        ],
        "args": [
          {
            "name": "source",
            "value": "\"x\""
          }
        ],
        "variant": null
      },
      "continuations": [
        {
          "branch": "token",
          "kind": "effect",
          "is_catchall": false,
          "binding": "t",
          "binding_type": "branch_payload",
          "condition": null,
          "step": {
            "type": "invocation",
            "invocation": {
              "event": [
                "consume_token"
              ],
              "args": [
                {
                  "name": "t",
                  "value": "t"
                }
              ],
              "variant": null
            }
          },
          "continuations": []
        },
        {
          "branch": "?",
          "kind": "effect",
          "is_catchall": true,
          "binding": null,
          "binding_type": "branch_payload",
          "condition": null,
          "step": {
            "type": "terminal"
          },
          "continuations": []
        },
        {
          "branch": "done",
          "kind": "terminal",
          "is_catchall": false,
          "binding": "n",
          "binding_type": "branch_payload",
          "condition": null,
          "step": {
            "type": "invocation",
            "invocation": {
              "event": [
                "end_run"
              ],
              "args": [
                {
                  "name": "n",
                  "value": "n"
                }
              ],
              "variant": null
            }
          },
          "continuations": []
        }
      ],
      "pre_label": null,
      "post_label": null,
      "impl_of": null,
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_077_effect_catchall_dispatch/input.kz",
        "line": 14,
        "col": 0
      }
    }
  ]
}

Test Configuration

PARSER_TEST