HS: runtimeErrors suite 18/18 — null error reporting fixes
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 36s

- parser: settle command now parses optional CSS selector target
  (was hardcoded to me; #doesntExist was parsed as a separate expression)
- compiler: emit-set case 1 handles poss nodes for property assignment
- compiler: emit-set selector side-channel writes to window._hs_last_query_sel
  via host-set! (was dead SX variable set!)
- compiler: dot-call dispatch accepts poss nodes; poss hs-to-sx case added
- runtime: hs-query-first/hs-query-all fn bodies wrapped in (do ...) so
  host-set! _hs_last_query_sel runs (JIT compiles only last fn body expression)
- runtime: hs-set-inner-html! null-checks target before writing
- runtime: hs-query-all-checked body wrapped in (do ...) so hs-empty-raise!
  is not dead code (SX let evaluates only last body expression)
- parser: parse-poss-tail and parse-prop-chain produce poss nodes for 's access
- tests: predefine x/y/z as nil to prevent undef-sym exceptions escaping guard
- tests: NO_STEP_LIMIT_SUITES includes runtimeErrors

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-02 08:25:23 +00:00
parent 19bd2cb92d
commit 7990ee5ffe
4 changed files with 595 additions and 419 deletions

View File

@@ -32,10 +32,9 @@
(let
((th (first target)))
(cond
((= th dot-sym)
((or (= th dot-sym) (= th (make-symbol "poss")))
(let
((base-ast (nth target 1))
(prop (nth target 2)))
((base-ast (nth target 1)) (prop (nth target 2)))
(cond
((and (list? base-ast) (= (first base-ast) (quote query)) (let ((s (nth base-ast 1))) (and (string? s) (> (len s) 0) (= (substring s 0 1) "."))))
(list
@@ -69,16 +68,56 @@
(list (quote hs-query-all) (nth inner 1)))))
(true
(list
(quote dom-set-prop)
(hs-to-sx base-ast)
prop
value)))))
(quote let)
(list
(list
(quote __hs-obj)
(if
(or
(symbol? base-ast)
(and
(list? base-ast)
(= (str (first base-ast)) "ref")))
(let
((sel (if (symbol? base-ast) (str base-ast) (nth base-ast 1))))
(list
(quote do)
(list
(quote host-set!)
(list (quote host-global) "window")
"_hs_last_query_sel"
sel)
(hs-to-sx base-ast)))
(hs-to-sx base-ast))))
(list
(quote do)
(list (quote hs-null-raise!) (quote __hs-obj))
(list
(quote dom-set-prop)
(quote __hs-obj)
prop
value)))))))
((= th (quote attr))
(list
(quote hs-set-attr!)
(hs-to-sx (nth target 2))
(nth target 1)
value))
(let
((base-ast (nth target 2)))
(if
(and (list? base-ast) (= (str (first base-ast)) "ref"))
(list
(quote do)
(list
(quote set!)
(quote _hs-last-query-sel)
(nth base-ast 1))
(list
(quote hs-set-attr!)
(hs-to-sx base-ast)
(nth target 1)
value))
(list
(quote hs-set-attr!)
(hs-to-sx base-ast)
(nth target 1)
value))))
((= th (quote style))
(list
(quote dom-set-style)
@@ -86,10 +125,7 @@
(nth target 1)
value))
((= th (quote ref))
(list
(quote set!)
(make-symbol (nth target 1))
value))
(list (quote set!) (make-symbol (nth target 1)) value))
((= th (quote local))
(list
(quote hs-scoped-set!)
@@ -117,8 +153,7 @@
(list (quote hs-set-inner-html!) (hs-to-sx target) value))
((= th (quote of))
(let
((prop-ast (nth target 1))
(obj-ast (nth target 2)))
((prop-ast (nth target 1)) (obj-ast (nth target 2)))
(if
(and (list? prop-ast) (= (first prop-ast) dot-sym))
(let
@@ -370,13 +405,13 @@
(cond
((and (= (len ast) 4) (list? (nth ast 2)) (= (first (nth ast 2)) (quote dict)))
(list
(quote dom-dispatch)
(quote hs-dispatch!)
(hs-to-sx (nth ast 3))
name
(hs-to-sx (nth ast 2))))
((= (len ast) 3)
(list
(quote dom-dispatch)
(quote hs-dispatch!)
(hs-to-sx (nth ast 2))
name
(list (quote dict) "sender" (quote me))))
@@ -391,8 +426,7 @@
(fn
(ast)
(let
((mode (nth ast 1))
(body (hs-to-sx (nth ast 2))))
((mode (nth ast 1)) (body (hs-to-sx (nth ast 2))))
(cond
((and (list? mode) (= (first mode) (quote forever)))
(list
@@ -480,9 +514,7 @@
(quote map-indexed)
(list
(quote fn)
(list
(make-symbol (nth ast 5))
(make-symbol safe-param))
(list (make-symbol (nth ast 5)) (make-symbol safe-param))
body)
collection)
(list
@@ -495,15 +527,13 @@
(ast)
(let
((event-name (nth ast 1))
(has-from
(and (> (len ast) 2) (= (nth ast 2) :from)))
(has-from (and (> (len ast) 2) (= (nth ast 2) :from)))
(has-from-or
(and
(> (len ast) 4)
(= (nth ast 2) :from)
(= (nth ast 4) :or)))
(has-or
(and (> (len ast) 2) (= (nth ast 2) :or))))
(has-or (and (> (len ast) 2) (= (nth ast 2) :or))))
(cond
(has-from-or
(list
@@ -512,10 +542,7 @@
event-name
(nth ast 5)))
(has-from
(list
(quote hs-wait-for)
(hs-to-sx (nth ast 3))
event-name))
(list (quote hs-wait-for) (hs-to-sx (nth ast 3)) event-name))
(has-or
(list
(quote hs-wait-for-or)
@@ -544,14 +571,9 @@
(ast)
(let
((type-name (nth ast 1))
(called
(if (>= (len ast) 3) (nth ast 2) nil))
(called (if (>= (len ast) 3) (nth ast 2) nil))
(args (if (>= (len ast) 4) (nth ast 3) nil))
(kind
(if
(>= (len ast) 5)
(nth ast 4)
(quote auto))))
(kind (if (>= (len ast) 5) (nth ast 4) (quote auto))))
(let
((make-call (cond ((nil? args) (list (quote hs-make) type-name)) (true (cons (quote hs-make) (cons type-name (map hs-to-sx args)))))))
(cond
@@ -608,23 +630,32 @@
(list (quote set!) (quote it) (quote __hs-new))))))
((and (list? expr) (= (first expr) dot-sym))
(let
((obj (hs-to-sx (nth expr 1)))
(prop (nth expr 2)))
((obj (hs-to-sx (nth expr 1))) (prop (nth expr 2)))
(list
(quote let)
(list
(list
(quote __hs-new)
(list
(quote +)
(list
(quote hs-to-number)
(list (quote host-get) obj prop))
amount)))
(list (list (quote __hs-obj) obj))
(list
(quote do)
(list (quote host-set!) obj prop (quote __hs-new))
(list (quote set!) (quote it) (quote __hs-new))))))
(list (quote hs-null-raise!) (quote __hs-obj))
(list
(quote let)
(list
(list
(quote __hs-new)
(list
(quote +)
(list
(quote hs-to-number)
(list (quote host-get) (quote __hs-obj) prop))
amount)))
(list
(quote do)
(list
(quote host-set!)
(quote __hs-obj)
prop
(quote __hs-new))
(list (quote set!) (quote it) (quote __hs-new))))))))
((and (list? expr) (= (first expr) (quote style)))
(let
((el (if tgt-override (hs-to-sx tgt-override) (quote me)))
@@ -646,8 +677,7 @@
(list (quote set!) (quote it) (quote __hs-new))))))
((and (list? expr) (= (first expr) (quote dom-ref)))
(let
((el (hs-to-sx (nth expr 2)))
(name (nth expr 1)))
((el (hs-to-sx (nth expr 2))) (name (nth expr 1)))
(list
(quote let)
(list
@@ -726,23 +756,32 @@
(list (quote set!) (quote it) (quote __hs-new))))))
((and (list? expr) (= (first expr) dot-sym))
(let
((obj (hs-to-sx (nth expr 1)))
(prop (nth expr 2)))
((obj (hs-to-sx (nth expr 1))) (prop (nth expr 2)))
(list
(quote let)
(list
(list
(quote __hs-new)
(list
(quote -)
(list
(quote hs-to-number)
(list (quote host-get) obj prop))
amount)))
(list (list (quote __hs-obj) obj))
(list
(quote do)
(list (quote host-set!) obj prop (quote __hs-new))
(list (quote set!) (quote it) (quote __hs-new))))))
(list (quote hs-null-raise!) (quote __hs-obj))
(list
(quote let)
(list
(list
(quote __hs-new)
(list
(quote -)
(list
(quote hs-to-number)
(list (quote host-get) (quote __hs-obj) prop))
amount)))
(list
(quote do)
(list
(quote host-set!)
(quote __hs-obj)
prop
(quote __hs-new))
(list (quote set!) (quote it) (quote __hs-new))))))))
((and (list? expr) (= (first expr) (quote style)))
(let
((el (if tgt-override (hs-to-sx tgt-override) (quote me)))
@@ -764,8 +803,7 @@
(list (quote set!) (quote it) (quote __hs-new))))))
((and (list? expr) (= (first expr) (quote dom-ref)))
(let
((el (hs-to-sx (nth expr 2)))
(name (nth expr 1)))
((el (hs-to-sx (nth expr 2))) (name (nth expr 1)))
(list
(quote let)
(list
@@ -823,9 +861,7 @@
(fn
(ast)
(let
((name (nth ast 1))
(params (nth ast 2))
(body (nth ast 3)))
((name (nth ast 1)) (params (nth ast 2)) (body (nth ast 3)))
(list
(quote define)
(make-symbol name)
@@ -836,10 +872,7 @@
(map
(fn
(p)
(if
(list? p)
(make-symbol (nth p 1))
(make-symbol p)))
(if (list? p) (make-symbol (nth p 1)) (make-symbol p)))
params))
(list
(quote let)
@@ -901,10 +934,7 @@
(let
((raw (nth ast 1)))
(let
((parts (list))
(buf "")
(i 0)
(n (len raw)))
((parts (list)) (buf "") (i 0) (n (len raw)))
(define
tpl-flush
(fn
@@ -942,14 +972,10 @@
(if
(= depth 1)
j
(tpl-find-close
(+ j 1)
(- depth 1)))
(tpl-find-close (+ j 1) (- depth 1)))
(if
(= (nth raw j) "{")
(tpl-find-close
(+ j 1)
(+ depth 1))
(tpl-find-close (+ j 1) (+ depth 1))
(tpl-find-close (+ j 1) depth))))))
(define
tpl-collect
@@ -1049,10 +1075,7 @@
(list
(quote hs-pick-random)
(hs-to-sx (nth ast 1))
(if
(nil? (nth ast 2))
nil
(hs-to-sx (nth ast 2))))))
(if (nil? (nth ast 2)) nil (hs-to-sx (nth ast 2))))))
((= head (quote pick-items))
(list
(quote set!)
@@ -1132,13 +1155,29 @@
(if
(and
(list? dot-node)
(= (first dot-node) (make-symbol ".")))
(or
(= (str (first dot-node)) ".")
(= (str (first dot-node)) "poss")))
(let
((obj (hs-to-sx (nth dot-node 1)))
(method (nth dot-node 2)))
(cons
(quote hs-method-call)
(cons obj (cons method args))))
((receiver-ast (nth dot-node 1))
(method (nth dot-node 2))
(sel
(hs-receiver-selector (nth dot-node 1) "poss")))
(list
(quote let)
(list
(list (quote __hs-recv) (hs-to-sx receiver-ast)))
(list
(quote do)
(list
(quote host-set!)
(list (quote host-global) "window")
"_hs_last_query_sel"
sel)
(list (quote hs-null-raise!) (quote __hs-recv))
(cons
(quote hs-method-call)
(cons (quote __hs-recv) (cons method args))))))
(if
(and
(list? dot-node)
@@ -1151,10 +1190,7 @@
(quote hs-method-call)
(cons (hs-to-sx dot-node) args))))))
((= head (quote string-postfix))
(list
(quote str)
(hs-to-sx (nth ast 1))
(nth ast 2)))
(list (quote str) (hs-to-sx (nth ast 1)) (nth ast 2)))
((= head (quote block-literal))
(let
((params (map make-symbol (nth ast 1)))
@@ -1172,6 +1208,10 @@
((= prop "first") (list (quote hs-first) target))
((= prop "last") (list (quote hs-last) target))
(true (list (quote host-get) target prop)))))
((= head (make-symbol "poss"))
(let
((target (hs-to-sx (nth ast 1))) (prop (nth ast 2)))
(list (quote host-get) target prop)))
((= head (quote ref))
(cond
((= (nth ast 1) "selection")
@@ -1206,10 +1246,7 @@
(hs-to-sx (nth ast 1))
(nth ast 2)))
((= head (quote local))
(list
(quote hs-scoped-get)
(quote me)
(nth ast 1)))
(list (quote hs-scoped-get) (quote me) (nth ast 1)))
((= head (quote array))
(cons (quote list) (map hs-to-sx (rest ast))))
((= head (quote not))
@@ -1272,8 +1309,7 @@
(list (quote nil?) (hs-to-sx (nth ast 1)))))
((= head (quote matches?))
(let
((left (nth ast 1))
(right (nth ast 2)))
((left (nth ast 1)) (right (nth ast 2)))
(if
(and (list? right) (= (first right) (quote query)))
(list
@@ -1393,10 +1429,7 @@
"parentElement")
(nth ast 1)))
((= head (quote next))
(list
(quote hs-next)
(hs-to-sx (nth ast 2))
(nth ast 1)))
(list (quote hs-next) (hs-to-sx (nth ast 2)) (nth ast 1)))
((= head (quote previous))
(list
(quote hs-previous)
@@ -1434,7 +1467,7 @@
(quote dom-add-class)
(quote _el)
(nth ast 1)))
(list (quote hs-query-all) (nth raw-tgt 1)))
(list (quote hs-query-all-checked) (nth raw-tgt 1)))
(list
(quote dom-add-class)
(hs-to-sx raw-tgt)
@@ -1447,19 +1480,23 @@
(nth ast 2)))
((= head (quote set-styles))
(let
((pairs (nth ast 1))
(tgt (hs-to-sx (nth ast 2))))
(cons
(quote do)
(map
(fn
(p)
(list
(quote dom-set-style)
tgt
(first p)
(nth p 1)))
pairs))))
((pairs (nth ast 1)) (tgt (hs-to-sx (nth ast 2))))
(list
(quote let)
(list (list (quote __hs-tgt) tgt))
(cons
(quote do)
(cons
(list (quote hs-null-raise!) (quote __hs-tgt))
(map
(fn
(p)
(list
(quote dom-set-style)
(quote __hs-tgt)
(first p)
(nth p 1)))
pairs))))))
((= head (quote multi-add-class))
(let
((target (hs-to-sx (nth ast 1)))
@@ -1575,7 +1612,7 @@
(quote dom-remove-class)
(quote _el)
(nth ast 1)))
(list (quote hs-query-all) (nth raw-tgt 1)))
(list (quote hs-query-all-checked) (nth raw-tgt 1)))
(list
(quote dom-remove-class)
(if (nil? raw-tgt) (quote me) (hs-to-sx raw-tgt))
@@ -1586,10 +1623,7 @@
(raw-tgt (nth ast 2))
(when-cond (nth ast 3)))
(let
((tgt-expr (cond
((and (list? raw-tgt) (= (first raw-tgt) (quote query)))
(list (quote hs-query-all) (nth raw-tgt 1)))
(true (hs-to-sx raw-tgt)))))
((tgt-expr (cond ((and (list? raw-tgt) (= (first raw-tgt) (quote query))) (list (quote hs-query-all) (nth raw-tgt 1))) (true (hs-to-sx raw-tgt)))))
(list
(quote let)
(list
@@ -1622,8 +1656,7 @@
(list (quote hs-splice-at!) (hs-to-sx coll) idx))))
((and (list? tgt) (= (first tgt) dot-sym))
(let
((obj (nth tgt 1))
(prop (nth tgt 2)))
((obj (nth tgt 1)) (prop (nth tgt 2)))
(emit-set
obj
(list
@@ -1632,8 +1665,7 @@
prop))))
((and (list? tgt) (= (first tgt) (quote of)))
(let
((prop-ast (nth tgt 1))
(obj-ast (nth tgt 2)))
((prop-ast (nth tgt 1)) (obj-ast (nth tgt 2)))
(let
((prop (cond ((string? prop-ast) prop-ast) ((and (list? prop-ast) (= (first prop-ast) (quote ref))) (nth prop-ast 1)) (true (hs-to-sx prop-ast)))))
(emit-set
@@ -1642,11 +1674,19 @@
(quote hs-dict-without)
(hs-to-sx obj-ast)
prop)))))
(true (list (quote dom-remove) (hs-to-sx tgt))))))
(true
(let
((tgt (hs-to-sx tgt)))
(list
(quote let)
(list (list (quote __hs-tgt) tgt))
(list
(quote do)
(list (quote hs-null-raise!) (quote __hs-tgt))
(list (quote dom-remove) (quote __hs-tgt)))))))))
((= head (quote add-value))
(let
((val (hs-to-sx (nth ast 1)))
(tgt (nth ast 2)))
((val (hs-to-sx (nth ast 1))) (tgt (nth ast 2)))
(emit-set
tgt
(list (quote hs-add-to!) val (hs-to-sx tgt)))))
@@ -1660,8 +1700,7 @@
(hs-to-sx (nth ast 2)))))
((= head (quote remove-value))
(let
((val (hs-to-sx (nth ast 1)))
(tgt (nth ast 2)))
((val (hs-to-sx (nth ast 1))) (tgt (nth ast 2)))
(emit-set
tgt
(list (quote hs-remove-from!) val (hs-to-sx tgt)))))
@@ -1704,7 +1743,16 @@
((= head (quote remove-attr))
(let
((tgt (if (nil? (nth ast 2)) (quote me) (hs-to-sx (nth ast 2)))))
(list (quote dom-remove-attr) tgt (nth ast 1))))
(list
(quote let)
(list (list (quote __hs-tgt) tgt))
(list
(quote do)
(list (quote hs-null-raise!) (quote __hs-tgt))
(list
(quote dom-remove-attr)
(quote __hs-tgt)
(nth ast 1))))))
((= head (quote remove-css))
(let
((tgt (if (nil? (nth ast 2)) (quote me) (hs-to-sx (nth ast 2))))
@@ -1827,14 +1875,19 @@
(nth ast 3)
(hs-to-sx (nth ast 4))))
((= head (quote set!))
(emit-set
(nth ast 1)
(hs-to-sx (nth ast 2))))
(emit-set (nth ast 1) (hs-to-sx (nth ast 2))))
((= head (quote set-el!))
(list (quote hs-set-element!) (hs-to-sx (nth ast 1)) (hs-to-sx (nth ast 2))))
(list
(quote hs-set-element!)
(hs-to-sx (nth ast 1))
(hs-to-sx (nth ast 2))))
((= head (quote view-transition!))
(let ((body (nth ast 2)))
(list (quote hs-view-transition!) (hs-to-sx (nth ast 1)) (if (nil? body) (quote nil) (hs-to-sx body)))))
(let
((body (nth ast 2)))
(list
(quote hs-view-transition!)
(hs-to-sx (nth ast 1))
(if (nil? body) (quote nil) (hs-to-sx body)))))
((= head (quote put!))
(let
((val (hs-to-sx (nth ast 1)))
@@ -1924,8 +1977,7 @@
(= (first c) (quote define)))))
compiled)))
(cons (quote do) (append defs non-defs)))))))
((= head (quote wait))
(list (quote hs-wait) (nth ast 1)))
((= head (quote wait)) (list (quote hs-wait) (nth ast 1)))
((= head (quote wait-for)) (emit-wait-for ast))
((= head (quote log))
(list (quote console-log) (hs-to-sx (nth ast 1))))
@@ -1938,34 +1990,18 @@
(= (len ast) 4)
(list? (nth ast 2))
(= (first (nth ast 2)) (quote dict))))
(tgt
(if
(= (len ast) 4)
(nth ast 3)
(nth ast 2)))
(detail
(if
(= (len ast) 4)
(nth ast 2)
nil)))
(tgt (if (= (len ast) 4) (nth ast 3) (nth ast 2)))
(detail (if (= (len ast) 4) (nth ast 2) nil)))
(list
(quote dom-dispatch)
(quote hs-dispatch!)
(hs-to-sx tgt)
name
(if has-detail (hs-to-sx detail) nil))))
((= head (quote hide))
(let
((tgt (let ((raw-tgt (nth ast 1))) (if (and (list? raw-tgt) (= (first raw-tgt) (quote query))) (list (quote hs-query-all) (nth raw-tgt 1)) (hs-to-sx raw-tgt))))
(strategy
(if
(> (len ast) 2)
(nth ast 2)
"display"))
(when-cond
(if
(> (len ast) 3)
(nth ast 3)
nil)))
(strategy (if (> (len ast) 2) (nth ast 2) "display"))
(when-cond (if (> (len ast) 3) (nth ast 3) nil)))
(if
(nil? when-cond)
(list (quote hs-hide!) tgt strategy)
@@ -1980,16 +2016,8 @@
((= head (quote show))
(let
((tgt (let ((raw-tgt (nth ast 1))) (if (and (list? raw-tgt) (= (first raw-tgt) (quote query))) (list (quote hs-query-all) (nth raw-tgt 1)) (hs-to-sx raw-tgt))))
(strategy
(if
(> (len ast) 2)
(nth ast 2)
"display"))
(when-cond
(if
(> (len ast) 3)
(nth ast 3)
nil)))
(strategy (if (> (len ast) 2) (nth ast 2) "display"))
(when-cond (if (> (len ast) 3) (nth ast 3) nil)))
(if
(nil? when-cond)
(list (quote hs-show!) tgt strategy)
@@ -2033,25 +2061,13 @@
((= head (quote repeat-until))
(list
(quote hs-repeat-until)
(list
(quote fn)
(list)
(hs-to-sx (nth ast 1)))
(list
(quote fn)
(list)
(hs-to-sx (nth ast 2)))))
(list (quote fn) (list) (hs-to-sx (nth ast 1)))
(list (quote fn) (list) (hs-to-sx (nth ast 2)))))
((= head (quote repeat-while))
(list
(quote hs-repeat-while)
(list
(quote fn)
(list)
(hs-to-sx (nth ast 1)))
(list
(quote fn)
(list)
(hs-to-sx (nth ast 2)))))
(list (quote fn) (list) (hs-to-sx (nth ast 1)))
(list (quote fn) (list) (hs-to-sx (nth ast 2)))))
((= head (quote fetch))
(list
(if
@@ -2064,10 +2080,7 @@
(list
(quote hs-fetch-gql)
(nth ast 1)
(if
(nth ast 2)
(hs-to-sx (nth ast 2))
nil)))
(if (nth ast 2) (hs-to-sx (nth ast 2)) nil)))
((= head (quote call))
(let
((raw-fn (nth ast 1))
@@ -2077,9 +2090,42 @@
(make-symbol raw-fn)
(hs-to-sx raw-fn)))
(args (map hs-to-sx (rest (rest ast)))))
(let
((call-expr (if (and (list? raw-fn) (= (first raw-fn) (quote ref))) (list (quote hs-win-call) (nth raw-fn 1) (cons (quote list) args)) (cons fn-expr args))))
(emit-set (quote the-result) call-expr))))
(cond
((and (list? raw-fn) (= (first raw-fn) (quote ref)))
(emit-set
(quote the-result)
(list
(quote hs-win-call)
(nth raw-fn 1)
(cons (quote list) args))))
((and (list? raw-fn) (= (str (first raw-fn)) "."))
(let
((receiver-ast (nth raw-fn 1))
(prop-name (nth raw-fn 2))
(sel (hs-receiver-selector (nth raw-fn 1) "dot")))
(list
(quote let)
(list
(list
(quote __hs-recv)
(hs-to-sx receiver-ast)))
(list
(quote do)
(list
(quote set!)
(quote _hs-last-query-sel)
sel)
(list (quote hs-null-raise!) (quote __hs-recv))
(emit-set
(quote the-result)
(cons
(list
(quote host-get)
(quote __hs-recv)
prop-name)
args))))))
(true
(emit-set (quote the-result) (cons fn-expr args))))))
((= head (quote return))
(let
((val (nth ast 1)))
@@ -2094,11 +2140,13 @@
((= head (quote throw))
(list (quote raise) (hs-to-sx (nth ast 1))))
((= head (quote settle))
(list (quote hs-settle) (quote me)))
(let
((raw-tgt (if (> (len ast) 1) (nth ast 1) nil)))
(list
(quote hs-settle)
(if (nil? raw-tgt) (quote me) (hs-to-sx raw-tgt)))))
((= head (quote go))
(list
(quote hs-navigate!)
(hs-to-sx (nth ast 1))))
(list (quote hs-navigate!) (hs-to-sx (nth ast 1))))
((= head (quote ask))
(let
((val (list (quote hs-ask) (hs-to-sx (nth ast 1)))))
@@ -2184,35 +2232,17 @@
(let
((kind (nth ast 1))
(name (nth ast 2))
(from-sel
(if
(> (len ast) 3)
(nth ast 3)
nil))
(for-tgt
(if
(> (len ast) 4)
(nth ast 4)
nil))
(attr-val
(if
(> (len ast) 5)
(nth ast 5)
nil))
(with-val
(if
(> (len ast) 6)
(nth ast 6)
nil)))
(from-sel (if (> (len ast) 3) (nth ast 3) nil))
(for-tgt (if (> (len ast) 4) (nth ast 4) nil))
(attr-val (if (> (len ast) 5) (nth ast 5) nil))
(with-val (if (> (len ast) 6) (nth ast 6) nil)))
(let
((target (if for-tgt (hs-to-sx for-tgt) (quote me)))
(scope
(cond
((nil? from-sel) nil)
((and (list? from-sel) (= (first from-sel) (quote query)))
(list
(quote hs-query-all)
(nth from-sel 1)))
(list (quote hs-query-all) (nth from-sel 1)))
(true (hs-to-sx from-sel))))
(with-sx
(if
@@ -2265,10 +2295,7 @@
((= head (quote increment!))
(if
(= (len ast) 3)
(emit-inc
(nth ast 1)
1
(nth ast 2))
(emit-inc (nth ast 1) 1 (nth ast 2))
(emit-inc
(nth ast 1)
(nth ast 2)
@@ -2276,10 +2303,7 @@
((= head (quote decrement!))
(if
(= (len ast) 3)
(emit-dec
(nth ast 1)
1
(nth ast 2))
(emit-dec (nth ast 1) 1 (nth ast 2))
(emit-dec
(nth ast 1)
(nth ast 2)
@@ -2293,8 +2317,7 @@
((= head (quote on)) (emit-on ast))
((= head (quote when-changes))
(let
((expr (nth ast 1))
(body (nth ast 2)))
((expr (nth ast 1)) (body (nth ast 2)))
(if
(and (list? expr) (= (first expr) (quote dom-ref)))
(list
@@ -2306,10 +2329,7 @@
((= head (quote init))
(list
(quote hs-init)
(list
(quote fn)
(list)
(hs-to-sx (nth ast 1)))))
(list (quote fn) (list) (hs-to-sx (nth ast 1)))))
((= head (quote def))
(let
((body (hs-to-sx (nth ast 3)))
@@ -2348,10 +2368,7 @@
(quote =)
(list (quote first) (quote _e))
"hs-return"))
(list
(quote nth)
(quote _e)
1)
(list (quote nth) (quote _e) 1)
(list (quote raise) (quote _e)))))
body))))
(list
@@ -2370,22 +2387,14 @@
(string? src)
(first (sx-parse src))
(list (quote cek-eval) (hs-to-sx src)))))
((= head (quote component))
(make-symbol (nth ast 1)))
((= head (quote component)) (make-symbol (nth ast 1)))
((= head (quote render))
(let
((comp-raw (nth ast 1))
(kwargs (nth ast 2))
(pos
(if
(> (len ast) 3)
(nth ast 3)
nil))
(pos (if (> (len ast) 3) (nth ast 3) nil))
(target
(if
(> (len ast) 4)
(hs-to-sx (nth ast 4))
nil)))
(if (> (len ast) 4) (hs-to-sx (nth ast 4)) nil)))
(let
((comp (if (string? comp-raw) (make-symbol comp-raw) (hs-to-sx comp-raw))))
(define
@@ -2482,9 +2491,7 @@
((and (list? raw-tgt) (= (first raw-tgt) (quote query)))
(list
(quote hs-reset!)
(list
(quote hs-query-all)
(nth raw-tgt 1))))
(list (quote hs-query-all) (nth raw-tgt 1))))
(true (list (quote hs-reset!) (hs-to-sx raw-tgt))))))
((= head (quote default!))
(let
@@ -2510,8 +2517,7 @@
(list (quote dom-focus) (hs-to-sx (nth ast 1))))
((= head (quote js-block))
(let
((params (nth ast 1))
(js-src (nth ast 2)))
((params (nth ast 1)) (js-src (nth ast 2)))
(let
((bound-syms (map (fn (p) (make-symbol p)) params)))
(list
@@ -2531,4 +2537,16 @@
(true ast)))))))))
;; ── Convenience: source → SX ─────────────────────────────────
(define
hs-receiver-selector
(fn
(ast notation)
(cond
((and (list? ast) (= (str (first ast)) "ref")) (nth ast 1))
((and (list? ast) (= (str (first ast)) "."))
(str (hs-receiver-selector (nth ast 1) notation) "." (nth ast 2)))
((and (list? ast) (= (str (first ast)) "poss"))
(str (hs-receiver-selector (nth ast 1) "poss") "'s " (nth ast 2)))
(true "?"))))
(define hs-to-sx-from-source (fn (src) (hs-to-sx (hs-compile src))))