HS: parse-cmd arith guard fixes — math/numbers/sourceInfo/stringPostfix (+14 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 42s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 42s
Three parse-cmd / parse-feat refinements:
1. Remove dict-branch from arith guard: span-mode=true produces dict nodes
with :kind "arith", not lists. The guard only needs the list-branch (for
span-mode=false). Without this, hs-src "x + y" threw a parse error.
2. parse-feat top-level expression-first fallback: when no feature keyword is
found, try parse-expr first. If it fully consumes the input (at-end?),
return the expression directly — bypassing parse-cmd and its arith guard.
This matches upstream _hyperscript("1 + 1") which evaluates as an
expression, not a pseudo-command.
3. paren-close exception in arith guard: when the token after the arithmetic
expression is ")", we are inside a parenthesised context (e.g. "(0+1) em"
string-postfix). Allow it through without the pseudo-command error.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2878,19 +2878,17 @@
|
||||
(let
|
||||
((expr (parse-expr)))
|
||||
(if
|
||||
(if
|
||||
(and (dict? expr) (get expr :hs-ast))
|
||||
(= (get expr :kind) "arith")
|
||||
(and
|
||||
(list? expr)
|
||||
(let
|
||||
((h (first expr)))
|
||||
(or
|
||||
(= h (quote +))
|
||||
(= h (quote -))
|
||||
(= h (quote *))
|
||||
(= h (quote /))
|
||||
(= h (make-symbol "%"))))))
|
||||
(and
|
||||
(list? expr)
|
||||
(not (= (tp-type) "paren-close"))
|
||||
(let
|
||||
((h (first expr)))
|
||||
(or
|
||||
(= h (quote +))
|
||||
(= h (quote -))
|
||||
(= h (quote *))
|
||||
(= h (quote /))
|
||||
(= h (make-symbol "%")))))
|
||||
(error "Pseudo-commands must be function calls")
|
||||
expr))))))))
|
||||
(define
|
||||
@@ -3220,7 +3218,15 @@
|
||||
(error
|
||||
"worker plugin is not installed — see https://hyperscript.org/features/worker"))
|
||||
((= val "bind") (do (adv!) (parse-bind-feat)))
|
||||
(true (parse-cmd-list))))))
|
||||
(true
|
||||
(let
|
||||
((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
|
||||
|
||||
Reference in New Issue
Block a user