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
|
(let
|
||||||
((expr (parse-expr)))
|
((expr (parse-expr)))
|
||||||
(if
|
(if
|
||||||
(if
|
(and
|
||||||
(and (dict? expr) (get expr :hs-ast))
|
(list? expr)
|
||||||
(= (get expr :kind) "arith")
|
(not (= (tp-type) "paren-close"))
|
||||||
(and
|
(let
|
||||||
(list? expr)
|
((h (first expr)))
|
||||||
(let
|
(or
|
||||||
((h (first expr)))
|
(= h (quote +))
|
||||||
(or
|
(= h (quote -))
|
||||||
(= h (quote +))
|
(= h (quote *))
|
||||||
(= h (quote -))
|
(= h (quote /))
|
||||||
(= h (quote *))
|
(= h (make-symbol "%")))))
|
||||||
(= h (quote /))
|
|
||||||
(= h (make-symbol "%"))))))
|
|
||||||
(error "Pseudo-commands must be function calls")
|
(error "Pseudo-commands must be function calls")
|
||||||
expr))))))))
|
expr))))))))
|
||||||
(define
|
(define
|
||||||
@@ -3220,7 +3218,15 @@
|
|||||||
(error
|
(error
|
||||||
"worker plugin is not installed — see https://hyperscript.org/features/worker"))
|
"worker plugin is not installed — see https://hyperscript.org/features/worker"))
|
||||||
((= val "bind") (do (adv!) (parse-bind-feat)))
|
((= 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
|
(define
|
||||||
coll-feats
|
coll-feats
|
||||||
(fn
|
(fn
|
||||||
|
|||||||
@@ -2878,19 +2878,17 @@
|
|||||||
(let
|
(let
|
||||||
((expr (parse-expr)))
|
((expr (parse-expr)))
|
||||||
(if
|
(if
|
||||||
(if
|
(and
|
||||||
(and (dict? expr) (get expr :hs-ast))
|
(list? expr)
|
||||||
(= (get expr :kind) "arith")
|
(not (= (tp-type) "paren-close"))
|
||||||
(and
|
(let
|
||||||
(list? expr)
|
((h (first expr)))
|
||||||
(let
|
(or
|
||||||
((h (first expr)))
|
(= h (quote +))
|
||||||
(or
|
(= h (quote -))
|
||||||
(= h (quote +))
|
(= h (quote *))
|
||||||
(= h (quote -))
|
(= h (quote /))
|
||||||
(= h (quote *))
|
(= h (make-symbol "%")))))
|
||||||
(= h (quote /))
|
|
||||||
(= h (make-symbol "%"))))))
|
|
||||||
(error "Pseudo-commands must be function calls")
|
(error "Pseudo-commands must be function calls")
|
||||||
expr))))))))
|
expr))))))))
|
||||||
(define
|
(define
|
||||||
@@ -3220,7 +3218,15 @@
|
|||||||
(error
|
(error
|
||||||
"worker plugin is not installed — see https://hyperscript.org/features/worker"))
|
"worker plugin is not installed — see https://hyperscript.org/features/worker"))
|
||||||
((= val "bind") (do (adv!) (parse-bind-feat)))
|
((= 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
|
(define
|
||||||
coll-feats
|
coll-feats
|
||||||
(fn
|
(fn
|
||||||
|
|||||||
Reference in New Issue
Block a user