Skip to content

parser: empty match-arm body Pat => {} is a parse error #644

Description

@hyperpolymath

Summary

An empty match-arm body Pat => {} is a parse error, while a non-empty block body parses fine. Downstream svalinn-gateway source uses empty arms (e.g. None => {}).

Repro

Fails:

module m;
enum Opt { SomeV(Int), NoneV }
pub fn f(o: Opt) -> Int {
  match o {
    SomeV(v) => { return v; }
    NoneV => {}
  }
  return 0;
}

parse error: Syntax error at the } closing the match.

Parses (contrast — non-empty body):

    NoneV => { return 0; }

Type checking passed.

So the empty {} block body specifically is the limitation.

Question / direction

Is an empty arm body intended-unsupported, or a grammar gap? If empty arms should be legal (unit-valued), the parser should accept => {}; otherwise a clearer diagnostic than a bare "Syntax error" would help downstream authors.

Note

The other downstream-flagged construct, pub extern fn, was checked and is supported — both check and compile succeed — so no issue is filed for it.

Context

Surfaced characterising svalinn-gateway gaps after the constructor-link fix (#138 / #602, ac98c81). Confirmed at main b8ba479.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions