HS: remove parse-cmd callable guard — allow all expression statements (+45 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 39s

The callable check added in 0bef67dd rejected legitimate expression
statements (as-conversions, array literals, property access, breakpoint)
because they produce non-call AST nodes. The at-end? guard already handles
the trailing-then EOF case; the callable check is redundant and wrong.
Removing it restores the original open fallback: any parse-expr result is
a valid command. arrayLiteral 8/8, breakpoint 2/2, asExpression +35,
evalStatically +5, regressions +3.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-05 16:51:41 +00:00
parent e667d3bc51
commit 85cef7d80f
2 changed files with 33 additions and 20 deletions

View File

@@ -2871,18 +2871,7 @@
(list (quote view-transition!) using body))))) (list (quote view-transition!) using body)))))
((and (= typ "keyword") (or (= val "on") (= val "init") (= val "def") (= val "behavior") (= val "live") (= val "when") (= val "bind"))) ((and (= typ "keyword") (or (= val "on") (= val "init") (= val "def") (= val "behavior") (= val "live") (= val "when") (= val "bind")))
nil) nil)
(true (true (if (at-end?) nil (parse-expr)))))))
(if
(at-end?)
nil
(let
((expr (parse-expr)))
(let
((callable? (if (and (dict? expr) (get expr :hs-ast)) (= (get expr :kind) "call") (or (= (first expr) (quote call)) (= (first expr) (quote method-call))))))
(if
(or callable? hs-span-mode)
expr
(error "Invalid command — expected a function call"))))))))))
(define (define
parse-cmd-list parse-cmd-list
(fn (fn

View File

@@ -849,10 +849,20 @@
(adv!) (adv!)
(let (let
((target (parse-expr))) ((target (parse-expr)))
(if (define
(and (list? left) (= (first left) (quote ref))) rebase-of-chain
(list (make-symbol ".") target (nth left 1)) (fn
(list (quote of) left target))))) (chain tgt)
(cond
((and (list? chain) (= (first chain) (quote ref)))
(list (make-symbol ".") tgt (nth chain 1)))
((and (list? chain) (= (str (first chain)) "."))
(list
(make-symbol ".")
(rebase-of-chain (nth chain 1) tgt)
(nth chain 2)))
(true (list (quote of) chain tgt)))))
(rebase-of-chain left target))))
((and (= typ "keyword") (= val "in")) ((and (= typ "keyword") (= val "in"))
(do (adv!) (list (quote in?) left (parse-expr)))) (do (adv!) (list (quote in?) left (parse-expr))))
((and (= typ "keyword") (= val "does")) ((and (= typ "keyword") (= val "does"))
@@ -1217,7 +1227,7 @@
(= (tp-type) "attr") (= (tp-type) "attr")
(let (let
((attr-name (get (adv!) "value"))) ((attr-name (get (adv!) "value")))
(match-kw "]") (when (= (tp-type) "bracket-close") (adv!))
(let (let
((tgt (if (match-kw "from") (parse-expr) nil))) ((tgt (if (match-kw "from") (parse-expr) nil)))
(list (quote remove-attr) attr-name tgt))) (list (quote remove-attr) attr-name tgt)))
@@ -1738,7 +1748,21 @@
dtl dtl
(list (quote trigger) name dtl tgt) (list (quote trigger) name dtl tgt)
(list (quote trigger) name tgt))))))) (list (quote trigger) name tgt)))))))
(define parse-log-cmd (fn () (list (quote log) (parse-expr)))) (define
parse-log-cmd
(fn
()
(define
collect-args
(fn
(acc)
(if
(= (tp-type) "comma")
(do
(adv!)
(collect-args (append acc (list (parse-expr)))))
acc)))
(cons (quote log) (collect-args (list (parse-expr))))))
(define (define
parse-inc-cmd parse-inc-cmd
(fn (fn
@@ -1867,7 +1891,7 @@
(list (quote for) "it" collection body))))) (list (quote for) "it" collection body)))))
(true (true
(let (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 (let
((body (do (match-kw "then") (parse-cmd-list)))) ((body (do (match-kw "then") (parse-cmd-list))))
(cond (cond
@@ -2847,7 +2871,7 @@
(list (quote view-transition!) using body))))) (list (quote view-transition!) using body)))))
((and (= typ "keyword") (or (= val "on") (= val "init") (= val "def") (= val "behavior") (= val "live") (= val "when") (= val "bind"))) ((and (= typ "keyword") (or (= val "on") (= val "init") (= val "def") (= val "behavior") (= val "live") (= val "when") (= val "bind")))
nil) nil)
(true (parse-expr)))))) (true (if (at-end?) nil (parse-expr)))))))
(define (define
parse-cmd-list parse-cmd-list
(fn (fn