HS: fix bare repeat — don't consume command keyword as count expression
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 34s

parse-repeat-cmd fallback called parse-expr on the next token, which
parse-atom would consume any keyword as (ref val). For bare `repeat`
followed by a command like `set`, this ate the `set` token so the loop
body started from the wrong position.

Fix: only attempt to parse a count expression when the next token is
a number, ident, or paren-open — the types that can form a numeric
count. Any keyword (set, put, if, end, …) means bare repeat-forever.

Fixes "repeat forever works w/o keyword" (+1 test).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-05 11:30:11 +00:00
parent 6a40e991b3
commit ac4e9ac96e

View File

@@ -1891,7 +1891,7 @@
(list (quote for) "it" collection body)))))
(true
(let
((mode (cond ((match-kw "forever") (list (quote forever))) ((match-kw "while") (list (quote while) (parse-expr))) ((match-kw "until") (list (quote until) (parse-expr))) (true (let ((n (parse-expr))) (if (match-kw "times") (list (quote times) n) (list (quote forever))))))))
((mode (cond ((match-kw "forever") (list (quote forever))) ((match-kw "while") (list (quote while) (parse-expr))) ((match-kw "until") (list (quote until) (parse-expr))) (true (if (or (= (tp-type) "number") (= (tp-type) "ident") (= (tp-type) "paren-open")) (let ((n (parse-expr))) (if (match-kw "times") (list (quote times) n) (list (quote forever)))) (list (quote forever)))))))
(let
((body (do (match-kw "then") (parse-cmd-list))))
(cond