You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
while cond { } silently accepted as ident+expr+block - emitted Go fails go vet (undefined: while); reserve while like mut #103
while is not a Hybrid keyword and not reserved by the lexer, so while cond { … } silently parses as an identifier expressionwhile, followed by expression cond, followed by a separate block statement. hyb check accepts it with 0 diagnostics; the emitter faithfully emits the ident + cond + orphan block as Go, and the emitted program fails go vet/go build with undefined: while.
This is the exact same class as the mut bug that was fixed by reserving mut in the KEYWORDS list (lexer.rs — the comment there documents the precedent). while was left unreserved.
Repro
fn main() {
x :=1while x > 0 {
x += 1
}
fmt.println(x)
}
for x > 0 { … } — Hybrid's actual while-form (ForKind::While) — accepted and emits valid Go for x > 0 { … }. This is the correct spelling.
loop { … } / for v in 0..n { … } — unaffected.
Suggested fix
Add while to the lexer KEYWORDS list (lexer.rs:74-116) and either:
Reject at parse with a clear diagnostic ("while is not a Hybrid keyword — use for cond { … } (while-form) or loop { … }"), mirroring how other reserved words behave; or
Accept as a while-loop (ForKind::While) — but only if the grammar deliberately wants a while alias; the docs/spec use for cond { }, so option 1 (reject) is the minimal honest fix and matches the mut precedent (keyword reserved, parse-level error, no silent bad emission).
Either way the failure mode changes from "accepted → invalid Go" to a proper parse/check-time diagnostic.
Environment
commit: 8fb9238 (origin/main) — repro re-verified on the fix-100-loop-label-scope build c8b0609 (unrelated fix; while bug present there too)
Activity
fix(hy-syntax): reserve while in KEYWORDS - parse error instead of si…
Merge pr-107 (milkingndb-oss, fixes limitlessprojects#103): `while` j…
hy-check: reject declarations named `default`, the one unreserved Go …
hy-check: reject declarations named `default`, the one unreserved Go …
hy-check: reject declarations named `default`, the one unreserved Go …