On this page

0032. Brace delimiters retain newlines inside parentheses

Context

The CP-4.2 review found that a global parenthesis counter erases statement and match-arm separators in call arguments. E0514's suggestion to put arms on separate lines cannot repair these programs. The owner requests a delimiter stack and unchanged existing goldens.

Decision

Track opening delimiters in the lexer; ignore newlines only when the innermost delimiter is ( or [. Braces restore newlines, including inside call arguments; nested parentheses suppress them again. Brackets remain unsupported syntax.

This supersedes the blanket newline-suppression assumption in ADR-0018 and ADR-0028 only. Their canonical output remains unchanged: retain existing parenthesized semicolon separators and match-arm commas even where now optional. This owner-requested extension deviates from the M4 plan's comma-required input rule because the old lexer also broke multiline if and nested block bodies.

Alternatives considered

Consequences

Semicolon-free multiline bodies work in both backends. An exact raw-source CLI regression checks execution and formatting idempotence; a program golden adds differential coverage. Existing syntax, output, diagnostics and traps stay stable.