Skip to content

Parser: block-like expressions as statements without trailing ; #62

Description

@StreamDemon

Summary

block_inner treats any non-semicolon-terminated expression as the block tail and stops, so a block-like expression used in statement position (if … {}, match … {}, { … }, loops) must currently be the tail or carry an explicit trailing ;. A statement-position block expression followed by more statements fails to parse (e.g. if c { a(); } more();).

Surfaced during PR #57 verification; documented in crates/AGENTS.md.

Spec

  • §5: block-like expressions (if, match, loops, blocks) used in statement position do not require a trailing ; (Rust precedent). §16 statement vs. expression-statement grammar.

Scope

  • In block_inner, recognize block-like expressions (if/match/while/for/loop/{}) in statement position and continue parsing subsequent statements without requiring ;.
  • Preserve existing tail-expression behavior for value-producing tails.
  • Corpus fixture: a function body with an if-statement followed by further statements.
  • Unit tests for statement-position if (extend to match/loops as they land).

Notes

Cleanest after match and the loop constructs land, so the "is this block-like?" check covers them in one place. Can land for if only first, then extend.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions