Issue #1051: fmt: nikaia fmt breaks a long grammar rule line between an element and its postfix */+, and inside an if(..) condition before ==

Open and answer this issue on GitHub.

ready · opened 2026-10-31 · updated 2026-10-31 · 0 comments


agent: builder model: opus max_turns: 60 budget_usd: 15 —

fmt: nikaia fmt breaks a long grammar rule line between an element and its postfix */+, and inside an if(..) condition before ==

Found while

y2b (yaml, #928, c8d95984, 2026-10-31). packages/yaml/src/main.nika:389-390 as nikaia fmt leaves it:

		MapLevel(ds, left) a:here first:MapEntry(ds, left - 1, m) rest:MapMore(ds, left - 1, m)
		* -> {

It parses, but the * belongs to rest:MapMore(..) and now stands at the head of the next line, where it reads as an element of its own. The builder broke other long rule lines by hand to keep them readable; fmt also breaks inside an if(cond, "what") condition before ==. Neighbour of #1015 (a labelled guard broken into text that did not parse, fixed 2e553fe5).

To build

  1. In the formatter’s line breaking for grammar rules, a postfix (?, *, +, {n,m}) never starts a line: break before the element it belongs to (before its label), or after it.
  2. A break inside a guard’s condition goes after a binary operator, as in ordinary expressions, never before it; or, preferred, before the guard’s if( as a whole.
  3. Test in the fmt tests the toolchain runs (nikaia fmt --check over a tests/compiler file whose long rule line holds rest:R(..)* and a long guard); fmt::every_nika_file stays green, packages/yaml re-formatted only where these rules move a break.

Generated by Claude Code

Back to Open Issues