ADR-390: A Subtraction’s - Is on the Line of What It Subtracts From — a - That Begins a Line Begins What Is Written There

Note (#1600, 2026-11-15): crates/nikaia-std/src/tools/ has moved to crates/nikaia-std/src/compiler/ (its generated Rust to compiler/lowered/). The text below keeps the old path; the Rust module is still nikaia_std::tools.

Status: Accepted Date: November 5, 2026 (supervisor’s decision, by the language principles) Answers: #1247 Related: ADR-135 D3 (a [ at the start of a line begins a literal); ADR-317 (the same rule for a call’s (); ADR-grammar-syntax-v1 D17 (same_line); Part I 3.1 (a statement begins a line)

1. Question

The grammar reads no newlines in an expression, so a line that begins with - was read as a subtraction from whatever the line before it ended with:

let n = run() catch {
    println("x")
    -1
}

was println("x") - 1: the block’s value became a subtraction from (), and rustc refused it. Nothing in the program looks like a subtraction. - is the one operator that is both binary and prefix; ! is prefix only, and +, *, &&, || and the comparisons cannot begin an expression, so a line that begins with one of them has only one reading.

2. How others do it

3. Options, weighed

Option For Against
A. A subtraction’s - on the line of its left operand (Go, Kotlin) The rule [ (ADR-135 D3) and ( (ADR-317) already have, read the same way; nothing new to learn A long subtraction broken before its - is written with the - at the end of the line instead
B. Read - by the space after it (Swift) Keeps a leading - x as a continuation A second rule, and one space changes what a line means
C. Keep the subtraction, warn (JavaScript linters) Nothing that parses today changes meaning A warning for a line that says exactly what it means

4. Decision

Option A.

D1 — A subtraction’s - is written on the line of what it subtracts from.

A - that is the first thing on its line is not a subtraction’s: it begins whatever is written there, a negative number or a negation. A subtraction broken over lines keeps its - at the end of the line it continues.

D2 — It is the rule ADR-135 D3 and ADR-317 made for [ and (, and read the same way.

The parser asks whether the - begins a line, from the whitespace it skipped (same_line, ADR-grammar-syntax-v1 D17); nothing is inserted and nothing is looked ahead for. An operator that cannot begin an expression (+, *, &&, ||, ==, !=, .., ?., .) still continues the line above when it begins a line.

5. Consequences

This site is open source. Improve this page.