From d5aa8a2e744093fb84e7037f10147f73fad1b021 Mon Sep 17 00:00:00 2001 From: giles Date: Mon, 4 May 2026 17:46:06 +0000 Subject: [PATCH] HS: coll-feats error on unconsumed tokens (+1 test) When parse-feat returns nil but the token stream is not at EOF, coll-feats now throws a parse error ('Unexpected token X') instead of silently returning the partial result. Fixes 'extra chars cause error when evaling': eval-hs("1!") now correctly throws because '!' is left over after parsing the number expression. Co-Authored-By: Claude Sonnet 4.6 --- lib/hyperscript/parser.sx | 14 +++++++++++++- shared/static/wasm/sx/hs-parser.sx | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/hyperscript/parser.sx b/lib/hyperscript/parser.sx index be58d2b6..d1413bbd 100644 --- a/lib/hyperscript/parser.sx +++ b/lib/hyperscript/parser.sx @@ -3133,7 +3133,19 @@ acc (let ((feat (parse-feat))) - (if (nil? feat) acc (coll-feats (append acc (list feat)))))))) + (if + (nil? feat) + (if + (at-end?) + acc + (error + (str + "Parse error: Unexpected token '" + (tp-val) + "' (line " + (get (nth tokens p) "line") + ")"))) + (coll-feats (append acc (list feat)))))))) (let ((features (coll-feats (list)))) (if diff --git a/shared/static/wasm/sx/hs-parser.sx b/shared/static/wasm/sx/hs-parser.sx index be58d2b6..d1413bbd 100644 --- a/shared/static/wasm/sx/hs-parser.sx +++ b/shared/static/wasm/sx/hs-parser.sx @@ -3133,7 +3133,19 @@ acc (let ((feat (parse-feat))) - (if (nil? feat) acc (coll-feats (append acc (list feat)))))))) + (if + (nil? feat) + (if + (at-end?) + acc + (error + (str + "Parse error: Unexpected token '" + (tp-val) + "' (line " + (get (nth tokens p) "line") + ")"))) + (coll-feats (append acc (list feat)))))))) (let ((features (coll-feats (list)))) (if