==================
Missing generate count preserves the completed flow header
==================
flow first:
  run before
  generate :
    Orphaned text.
  ## Following.
  run after
## Next.
flow next:
  pass

---

(program
  (flow
    (runnable_name)
    (newline)
    (flow_body
      (run_stmt
        (runnable_name)
        (newline))
      (ERROR
        (newline))
      (blank_line)
      (item_doc
        (text))
      (run_stmt
        (runnable_name)
        (newline))))
  (item_doc
    (text))
  (flow
    (runnable_name)
    (newline)
    (flow_body
      (newline))))

==================
Incomplete repeat options cannot borrow the next declaration's colon
==================
flow first:
  repeat 2 times windowing 1,
    run worker
    until ready
## Next.
flow next:
  pass

---

(program
  (flow
    (runnable_name)
    (newline)
    (flow_body
      (ERROR
        (integer_literal)
        (integer_literal)
        (newline)
        (blank_line))
      (blank_line)
      (invalid_missing_body)))
  (item_doc
    (text))
  (flow
    (runnable_name)
    (newline)
    (flow_body
      (newline))))

==================
A malformed return annotation cannot borrow the next declaration's colon
==================
agic first(_: Text) -> J[on:
  models = fast
  recall = near
  tool: Body.
## Next.
flow next:
  pass

---

(program
  (ERROR
    (runnable_name)
    (params
      (param
        (param_name)
        (type
          (builtin_type))))
    (type
      (type_name))
    (newline)
    (blank_line)
    (blank_line))
  (blank_line)
  (item_doc
    (text))
  (flow
    (runnable_name)
    (newline)
    (flow_body
      (newline))))

==================
Missing filter connector preserves a nested repeat header
==================
flow first:
  run before
  repeat:
    run inner
    keep in 2 lanes:
      Orphaned text.
    ## Following.
    run after
  run after_outer
## Next.
flow next:
  pass

---

(program
  (flow
    (runnable_name)
    (newline)
    (flow_body
      (run_stmt
        (runnable_name)
        (newline))
      (repeat_stmt
        (newline)
        (repeat_body
          (run_stmt
            (runnable_name)
            (newline))
          (ERROR
            (integer_literal)
            (newline))
          (blank_line)
          (item_doc
            (text))
          (run_stmt
            (runnable_name)
            (newline))))
      (run_stmt
        (runnable_name)
        (newline))))
  (item_doc
    (text))
  (flow
    (runnable_name)
    (newline)
    (flow_body
      (newline))))

==================
Malformed bound sort preserves its enclosing headers
==================
flow first:
  run before
  repeat:
    run inner
    let value = sort ascending:
      Orphaned text.
    ## Following.
    run after
  run after_outer
## Next.
flow next:
  pass

---

(program
  (flow
    (runnable_name)
    (newline)
    (flow_body
      (run_stmt
        (runnable_name)
        (newline))
      (repeat_stmt
        (newline)
        (repeat_body
          (run_stmt
            (runnable_name)
            (newline))
          (let_stmt
            (local_name)
            (ERROR)
            (newline)
            (content
              (text)
              (newline)))
          (item_doc
            (text))
          (run_stmt
            (runnable_name)
            (newline))))
      (run_stmt
        (runnable_name)
        (newline))))
  (item_doc
    (text))
  (flow
    (runnable_name)
    (newline)
    (flow_body
      (newline))))
