loop { … } with a body is refused as a misread struct literal (“let is a reserved word”) instead of NK1117 with the while true help (ADR-298 D7)Open and answer this issue on GitHub.
ready · opened 2026-11-05 · updated 2026-11-05 · 0 comments
ADR-298 D7 says that loop { … } written as a statement, where nothing declares loop, is NK1117 with the help write while true { … }. The sentence exists (check_words.nika:12), but the parser never reaches it once the block has a body: it reads loop { as the start of a struct literal and refuses the first statement inside with a message that names the wrong word.
Found while writing tests/page-examples (9350a4d): loop { followed by a let gave “let is a reserved word”.
fn main() {
loop {
let x = 1
break
}
}
nikaia check (develop, 9350a4d):
error: `let` is a reserved word, so it can't be used as a name here.
--> loop2.nika:3:9
|
3 | let x = 1
| ^^^
|
= note: Expected `}` here, but found `let`.
= help: Choose another name, such as `let_`.
The same for the other first statements:
loop { break } → “break is a reserved word … such as break_”loop { println("x") } → “Expected } here, but found (.”loop { n += 1 … } → “Expected } here, but found +.”ADR-298 D7, as its table says:
error[NK1117]: … `loop` …
= help: Nikaia has no `loop` keyword. Write `while true { … }`. (`loop` is an ordinary name, so `let loop = 3` is fine.)
And nothing is said where loop is declared, for example a struct named loop built with a literal (D7, last sentence).
loop followed by {, and the struct-literal reading fails on the first token inside the braces, report NK1117 with the D7 help at loop instead of the struct-literal parse error. A declared loop (a struct or a binding) keeps today’s reading.tests/compiler/ with their .stderr: loop { let … }, loop { break }, loop { f() }, and a declared struct loop { … } literal that still works.const X = … and macro … / quote … (the other rows of D7) reach their help with the same kinds of right-hand side, and cover them the same way if not.