HS: fix empty multi-element + meta reserved var in for loop
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 16s

This commit is contained in:
2026-04-26 22:46:51 +00:00
parent 68d81f59a6
commit 5ddd558eb7
2 changed files with 20 additions and 4 deletions

View File

@@ -413,11 +413,14 @@
(hs-to-sx mode) (hs-to-sx mode)
(list (quote fn) (list) body))))))) (list (quote fn) (list) body)))))))
(define (define
hs-reserved-var?
(fn (name) (or (= name "meta") (= name "event") (= name "it") (= name "result")))
emit-for emit-for
(fn (fn
(ast) (ast)
(let (let
((var-name (nth ast 1)) ((var-name (nth ast 1))
(safe-param (if (hs-reserved-var? var-name) (str "_hs_lv_" var-name) var-name))
(raw-coll-ast (nth ast 2)) (raw-coll-ast (nth ast 2))
(where-cond (where-cond
(if (if
@@ -452,12 +455,12 @@
(quote map-indexed) (quote map-indexed)
(list (list
(quote fn) (quote fn)
(list (make-symbol (nth ast 5)) (make-symbol var-name)) (list (make-symbol (nth ast 5)) (make-symbol safe-param))
body) body)
collection) collection)
(list (list
(quote hs-for-each) (quote hs-for-each)
(list (quote fn) (list (make-symbol var-name)) body) (list (quote fn) (list (make-symbol safe-param)) body)
collection))))) collection)))))
(define (define
emit-wait-for emit-wait-for
@@ -1556,6 +1559,11 @@
(emit-set (emit-set
tgt tgt
(list (quote hs-empty-like) (hs-to-sx tgt)))) (list (quote hs-empty-like) (hs-to-sx tgt))))
((and (list? tgt) (= (first tgt) (quote query)))
(list
(quote for-each)
(list (quote fn) (list (quote _el)) (list (quote hs-empty-target!) (quote _el)))
(list (quote hs-query-all) (nth tgt 1))))
(true (list (quote hs-empty-target!) (hs-to-sx tgt)))))) (true (list (quote hs-empty-target!) (hs-to-sx tgt))))))
((= head (quote open-element)) ((= head (quote open-element))
(list (quote hs-open!) (hs-to-sx (nth ast 1)))) (list (quote hs-open!) (hs-to-sx (nth ast 1))))

View File

@@ -413,11 +413,14 @@
(hs-to-sx mode) (hs-to-sx mode)
(list (quote fn) (list) body))))))) (list (quote fn) (list) body)))))))
(define (define
hs-reserved-var?
(fn (name) (or (= name "meta") (= name "event") (= name "it") (= name "result")))
emit-for emit-for
(fn (fn
(ast) (ast)
(let (let
((var-name (nth ast 1)) ((var-name (nth ast 1))
(safe-param (if (hs-reserved-var? var-name) (str "_hs_lv_" var-name) var-name))
(raw-coll-ast (nth ast 2)) (raw-coll-ast (nth ast 2))
(where-cond (where-cond
(if (if
@@ -452,12 +455,12 @@
(quote map-indexed) (quote map-indexed)
(list (list
(quote fn) (quote fn)
(list (make-symbol (nth ast 5)) (make-symbol var-name)) (list (make-symbol (nth ast 5)) (make-symbol safe-param))
body) body)
collection) collection)
(list (list
(quote hs-for-each) (quote hs-for-each)
(list (quote fn) (list (make-symbol var-name)) body) (list (quote fn) (list (make-symbol safe-param)) body)
collection))))) collection)))))
(define (define
emit-wait-for emit-wait-for
@@ -1556,6 +1559,11 @@
(emit-set (emit-set
tgt tgt
(list (quote hs-empty-like) (hs-to-sx tgt)))) (list (quote hs-empty-like) (hs-to-sx tgt))))
((and (list? tgt) (= (first tgt) (quote query)))
(list
(quote for-each)
(list (quote fn) (list (quote _el)) (list (quote hs-empty-target!) (quote _el)))
(list (quote hs-query-all) (nth tgt 1))))
(true (list (quote hs-empty-target!) (hs-to-sx tgt)))))) (true (list (quote hs-empty-target!) (hs-to-sx tgt))))))
((= head (quote open-element)) ((= head (quote open-element))
(list (quote hs-open!) (hs-to-sx (nth ast 1)))) (list (quote hs-open!) (hs-to-sx (nth ast 1))))