HS: fix repeat-in loop variable binding + dict insertion order (+4 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
Two fixes: (1) compiler.sx: remove `it` from hs-reserved-var?. `it` is the standard HS loop variable for `repeat in` loops; renaming it to `_hs_lv_it` made the body reference the outer (nil) `it` rather than the bound element. Other reserved vars (meta, event, result) still get renamed to prevent shadowing built-ins in misnamed loops. (2) runtime.sx: hs-make-object now appends an `_order` list tracking insertion order, mirroring the pattern used by other dict-building paths. Without this, `for prop in obj` fell back to `(keys obj)` which gives non-deterministic key order for objects with string keys. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -463,13 +463,7 @@
|
|||||||
(list (quote fn) (list) body)))))))
|
(list (quote fn) (list) body)))))))
|
||||||
(define
|
(define
|
||||||
hs-reserved-var?
|
hs-reserved-var?
|
||||||
(fn
|
(fn (name) (or (= name "meta") (= name "event") (= name "result"))))
|
||||||
(name)
|
|
||||||
(or
|
|
||||||
(= name "meta")
|
|
||||||
(= name "event")
|
|
||||||
(= name "it")
|
|
||||||
(= name "result"))))
|
|
||||||
(define
|
(define
|
||||||
emit-for
|
emit-for
|
||||||
(fn
|
(fn
|
||||||
|
|||||||
@@ -2330,7 +2330,16 @@
|
|||||||
((d {}))
|
((d {}))
|
||||||
(do
|
(do
|
||||||
(for-each
|
(for-each
|
||||||
(fn (pair) (dict-set! d (first pair) (nth pair 1)))
|
(fn
|
||||||
|
(pair)
|
||||||
|
(let
|
||||||
|
((name (first pair)))
|
||||||
|
(do
|
||||||
|
(dict-set! d name (nth pair 1))
|
||||||
|
(dict-set!
|
||||||
|
d
|
||||||
|
"_order"
|
||||||
|
(append (or (get d "_order") (list)) (list name))))))
|
||||||
pairs)
|
pairs)
|
||||||
d))))
|
d))))
|
||||||
|
|
||||||
|
|||||||
@@ -463,13 +463,7 @@
|
|||||||
(list (quote fn) (list) body)))))))
|
(list (quote fn) (list) body)))))))
|
||||||
(define
|
(define
|
||||||
hs-reserved-var?
|
hs-reserved-var?
|
||||||
(fn
|
(fn (name) (or (= name "meta") (= name "event") (= name "result"))))
|
||||||
(name)
|
|
||||||
(or
|
|
||||||
(= name "meta")
|
|
||||||
(= name "event")
|
|
||||||
(= name "it")
|
|
||||||
(= name "result"))))
|
|
||||||
(define
|
(define
|
||||||
emit-for
|
emit-for
|
||||||
(fn
|
(fn
|
||||||
|
|||||||
@@ -2330,7 +2330,16 @@
|
|||||||
((d {}))
|
((d {}))
|
||||||
(do
|
(do
|
||||||
(for-each
|
(for-each
|
||||||
(fn (pair) (dict-set! d (first pair) (nth pair 1)))
|
(fn
|
||||||
|
(pair)
|
||||||
|
(let
|
||||||
|
((name (first pair)))
|
||||||
|
(do
|
||||||
|
(dict-set! d name (nth pair 1))
|
||||||
|
(dict-set!
|
||||||
|
d
|
||||||
|
"_order"
|
||||||
|
(append (or (get d "_order") (list)) (list name))))))
|
||||||
pairs)
|
pairs)
|
||||||
d))))
|
d))))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user