From c26cd500b4728106f7cbc4ee596551388d042f66 Mon Sep 17 00:00:00 2001 From: giles Date: Tue, 5 May 2026 14:16:29 +0000 Subject: [PATCH] =?UTF-8?q?HS:=20parse-cmd=20pseudo-command=20validation?= =?UTF-8?q?=20=E2=80=94=20only=20enforce=20callable=20check=20in=20non-spa?= =?UTF-8?q?n=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In span mode (hs-parse-ast), parse-cmd is used to extract source info from arbitrary expressions like literals and property access — not just callables. Guard the "expected function call" error with hs-span-mode so span mode passes all expression types through, while execution mode still rejects non-callable expressions. Also handle span mode's hs-ast dict nodes (kind="call") in the callable? check, since method calls are wrapped in span mode. --- lib/hyperscript/parser.sx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/hyperscript/parser.sx b/lib/hyperscript/parser.sx index cdc40b60..ac4cf828 100644 --- a/lib/hyperscript/parser.sx +++ b/lib/hyperscript/parser.sx @@ -2874,15 +2874,12 @@ (true (let ((expr (parse-expr))) - (if - (or - (= (first expr) (quote call)) - (= (first expr) (quote method-call))) - expr - (error - (str - "Invalid command — expected a function call, got: " - (str (first 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 parse-cmd-list (fn