Skip to content

Parse expression statements consistently in nested blocks #478

Closed

Description

@LunaStev

Problem

Nested blocks reject expression statements that the outer function-body parser accepts because their expression-start predicate is incomplete.

fun main() -> i32 {
    if (true) {
        true;
    }
    return 0;
}

On current master plus PR #474, wavec check rejects the semicolon after the boolean literal. The expression parser supports boolean and prefix expressions, but is_expression_start in front/parser/src/parser/types.rs does not enumerate the same set. This is another symptom of the duplicated body parsers tracked by the malformed-function-body audit.

The accepted grammar must not depend on block nesting when moving to alpha.

Scope

  • Make expression-start detection derive from or stay exhaustively aligned with the expression parser.
  • Cover boolean, null, grouping, literals, identifiers, calls, dereference, address-of, unary arithmetic, and logical prefix expressions.
  • Add the same expression-statement table at function-body and nested-block depth.
  • Coordinate with the function-body consolidation issue so fixes do not introduce a third grammar list.

Acceptance criteria

  • Valid expression statements parse consistently at every block depth.
  • Unsupported starts fail with a structured diagnostic instead of being skipped.
  • Tests fail if a future expression form is added without block-statement coverage.

Related: #395, #399, #474

Activity

  1. added
    bug
    good first issue
    needs testing
    on Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issueneeds testing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions