080 nested when guards

✓ Passing This code compiles and runs correctly.

Code

// TEST: Nested continuations with when-guards should parse without parse_error nodes.

~event run {}
| ready { t: i32 }
| err {}

~event poll { t: i32 }
| key { code: u8 }
| done {}

~event cleanup {}
| done {}

~event handle_key { code: u8 }
| done {}

~run()
| ready t |> poll(t: t.t)
    | key k when (k.code == 'q') |> cleanup()
        | done |> _
    | key k |> handle_key(code: k.code)
        | done |> _
    | done |> _
| err _ |> _
input.kz

Expected AST

{
  "module_annotations": [],
  "items": [
    {
      "type": "import_decl",
      "path": "$std/compiler",
      "location": {
        "file": "tests/regression/100_PARSER/100_080_nested_when_guards/input.kz",
        "line": 2,
        "col": 0
      }
    },
    {
      "type": "host_line",
      "module": "input",
      "location": {
        "file": "tests/regression/100_PARSER/100_080_nested_when_guards/input.kz",
        "line": 2,
        "col": 0
      }
    },
    {
      "type": "event_decl",
      "name": "run",
      "path": [
        "run"
      ],
      "module": "input",
      "input": {
        "fields": []
      },
      "branches": [
        {
          "name": "ready",
          "payload": {
            "fields": [
              {
                "name": "t",
                "type": "i32",
                "is_source": false,
                "is_file": false,
                "is_embed_file": false,
                "is_expression": false,
                "is_invocation_meta": false,
                "phantom": null
              }
            ]
          }
        },
        {
          "name": "err",
          "payload": {
            "fields": []
          }
        }
      ],
      "location": {
        "file": "tests/regression/100_PARSER/100_080_nested_when_guards/input.kz",
        "line": 7,
        "col": 0
      }
    },
    {
      "type": "event_decl",
      "name": "poll",
      "path": [
        "poll"
      ],
      "module": "input",
      "input": {
        "fields": [
          {
            "name": "t",
            "type": "i32",
            "is_source": false,
            "is_file": false,
            "is_embed_file": false,
            "is_expression": false,
            "is_invocation_meta": false,
            "phantom": null
          }
        ]
      },
      "branches": [
        {
          "name": "key",
          "payload": {
            "fields": [
              {
                "name": "code",
                "type": "u8",
                "is_source": false,
                "is_file": false,
                "is_embed_file": false,
                "is_expression": false,
                "is_invocation_meta": false,
                "phantom": null
              }
            ]
          }
        },
        {
          "name": "done",
          "payload": {
            "fields": []
          }
        }
      ],
      "location": {
        "file": "tests/regression/100_PARSER/100_080_nested_when_guards/input.kz",
        "line": 11,
        "col": 0
      }
    },
    {
      "type": "event_decl",
      "name": "cleanup",
      "path": [
        "cleanup"
      ],
      "module": "input",
      "input": {
        "fields": []
      },
      "branches": [
        {
          "name": "done",
          "payload": {
            "fields": []
          }
        }
      ],
      "location": {
        "file": "tests/regression/100_PARSER/100_080_nested_when_guards/input.kz",
        "line": 14,
        "col": 0
      }
    },
    {
      "type": "event_decl",
      "name": "handle_key",
      "path": [
        "handle_key"
      ],
      "module": "input",
      "input": {
        "fields": [
          {
            "name": "code",
            "type": "u8",
            "is_source": false,
            "is_file": false,
            "is_embed_file": false,
            "is_expression": false,
            "is_invocation_meta": false,
            "phantom": null
          }
        ]
      },
      "branches": [
        {
          "name": "done",
          "payload": {
            "fields": []
          }
        }
      ],
      "location": {
        "file": "tests/regression/100_PARSER/100_080_nested_when_guards/input.kz",
        "line": 17,
        "col": 0
      }
    },
    {
      "type": "flow",
      "invocation": {
        "event": [
          "run"
        ],
        "args": [],
        "variant": null
      },
      "continuations": [
        {
          "branch": "ready",
          "binding": "t",
          "binding_type": "branch_payload",
          "condition": null,
          "step": {
            "type": "invocation",
            "invocation": {
              "event": [
                "poll"
              ],
              "args": [
                {
                  "name": "t",
                  "value": "t.t"
                }
              ],
              "variant": null
            }
          },
          "continuations": [
            {
              "branch": "key",
              "binding": "k",
              "binding_type": "branch_payload",
              "condition": "(k.code == 'q')",
              "step": {
                "type": "invocation",
                "invocation": {
                  "event": [
                    "cleanup"
                  ],
                  "args": [],
                  "variant": null
                }
              },
              "continuations": [
                {
                  "branch": "done",
                  "binding": null,
                  "binding_type": "branch_payload",
                  "condition": null,
                  "step": {
                    "type": "terminal"
                  },
                  "continuations": []
                }
              ]
            },
            {
              "branch": "key",
              "binding": "k",
              "binding_type": "branch_payload",
              "condition": null,
              "step": {
                "type": "invocation",
                "invocation": {
                  "event": [
                    "handle_key"
                  ],
                  "args": [
                    {
                      "name": "code",
                      "value": "k.code"
                    }
                  ],
                  "variant": null
                }
              },
              "continuations": [
                {
                  "branch": "done",
                  "binding": null,
                  "binding_type": "branch_payload",
                  "condition": null,
                  "step": {
                    "type": "terminal"
                  },
                  "continuations": []
                }
              ]
            },
            {
              "branch": "done",
              "binding": null,
              "binding_type": "branch_payload",
              "condition": null,
              "step": {
                "type": "terminal"
              },
              "continuations": []
            }
          ]
        },
        {
          "branch": "err",
          "binding": "_",
          "binding_type": "branch_payload",
          "condition": null,
          "step": {
            "type": "terminal"
          },
          "continuations": []
        }
      ],
      "pre_label": null,
      "post_label": null,
      "impl_of": null,
      "location": {
        "file": "tests/regression/100_PARSER/100_080_nested_when_guards/input.kz",
        "line": 18,
        "col": 0
      }
    }
  ]
}

Test Configuration

PARSER_TEST