On this page

0018. Semicolon-free canonical formatting

Context

T0 compiled and ran all 30 programs successfully, but 0/30 passed fmt --check. Models generally wrote newline-terminated statements without semicolons and short if expressions on one line; the formatter added semicolons and expanded those expressions.

Decision

Maintainer chooses semicolon-free canonical formatting: omit statement semicolons except where needed to separate statements inside parentheses, where newlines are ignored. Keep short if/else expressions on one line when they fit within 100 columns including indentation; otherwise expand them. Eligible branches each contain one expression statement without blocks, nested if or interpolation; there must be a block else (not else if) and no comment in the if's span. An else if chain is never inlined, so a chain keeps one multi-line layout. Preserve syntax and comment text/order.

This supersedes ADR-0015 for the semicolon and one-line-if rules only; the rest stands. This changes canonical formatting, not accepted syntax.

Alternatives considered

Consequences

M2.4's formatter revision follows the observed style while retaining required separators inside parentheses, idempotence and the other ADR-0015 guarantees. Canonical examples and formatter checks must reflect the revised style; T0's historical results remain evidence, not a measurement of the revised formatter.