From 42c7a593cff4649ce497d7db8751db8e27f54f73 Mon Sep 17 00:00:00 2001 From: giles Date: Tue, 5 May 2026 19:27:19 +0000 Subject: [PATCH] =?UTF-8?q?HS:=20parse-feat=20keyword-first=20guard=20?= =?UTF-8?q?=E2=80=94=20fix=20assert-throws=20for=20command-like=20scripts?= =?UTF-8?q?=20(+2=20tests)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit parse-feat true fallback now routes directly to parse-cmd-list when the first token is a keyword (e.g. "add - to"), so command-keyword scripts always produce parse errors rather than being treated as subtraction expressions. Non-keyword tokens (numbers, identifiers, paren-open) still try expression-first. Co-Authored-By: Claude Sonnet 4.6 --- lib/hyperscript/parser.sx | 17 ++++++++++------- shared/static/wasm/sx/hs-parser.sx | 17 ++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/hyperscript/parser.sx b/lib/hyperscript/parser.sx index 8a125aaa..392b550b 100644 --- a/lib/hyperscript/parser.sx +++ b/lib/hyperscript/parser.sx @@ -3219,14 +3219,17 @@ "worker plugin is not installed — see https://hyperscript.org/features/worker")) ((= val "bind") (do (adv!) (parse-bind-feat))) (true - (let - ((saved-p p)) + (if + (= (tp-type) "keyword") + (parse-cmd-list) (let - ((expr (guard (_e (true nil)) (parse-expr)))) - (if - (and expr (at-end?)) - expr - (do (set! p saved-p) (parse-cmd-list)))))))))) + ((saved-p p)) + (let + ((expr (guard (_e (true nil)) (parse-expr)))) + (if + (and expr (at-end?)) + expr + (do (set! p saved-p) (parse-cmd-list))))))))))) (define coll-feats (fn diff --git a/shared/static/wasm/sx/hs-parser.sx b/shared/static/wasm/sx/hs-parser.sx index 8a125aaa..392b550b 100644 --- a/shared/static/wasm/sx/hs-parser.sx +++ b/shared/static/wasm/sx/hs-parser.sx @@ -3219,14 +3219,17 @@ "worker plugin is not installed — see https://hyperscript.org/features/worker")) ((= val "bind") (do (adv!) (parse-bind-feat))) (true - (let - ((saved-p p)) + (if + (= (tp-type) "keyword") + (parse-cmd-list) (let - ((expr (guard (_e (true nil)) (parse-expr)))) - (if - (and expr (at-end?)) - expr - (do (set! p saved-p) (parse-cmd-list)))))))))) + ((saved-p p)) + (let + ((expr (guard (_e (true nil)) (parse-expr)))) + (if + (and expr (at-end?)) + expr + (do (set! p saved-p) (parse-cmd-list))))))))))) (define coll-feats (fn