js-on-sx: scope var defines + js-args for call args
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s

JS top-level var was emitting (define <name> X) at SX top level,
permanently rebinding any SX primitive of that name (e.g. var list
= X broke (list ...) globally). Two-part fix:
1. wrap transpiled program in (let () ...) in js-eval so defines
   scope to the eval and don't leak.
2. rename call-args constructor in js-transpile-args from list to
   js-args (a variadic alias) so even within the eval's own scope,
   JS vars named list don't shadow arg construction.
Array-literal transpile keeps list (arrays must be mutable).
built-ins/Object: 41/50 → 42/50. conformance.sh: 148/148.
This commit is contained in:
2026-05-07 23:55:07 +00:00
parent 06a5b5b07c
commit 82100603f0
5 changed files with 51 additions and 47 deletions

View File

@@ -426,7 +426,7 @@
(list (js-sym "list") "js-spread" (js-transpile (nth e 1)))
(list (js-sym "list") "js-value" (js-transpile e))))
args))
(cons (js-sym "list") (map js-transpile args)))))
(cons (js-sym "js-args") (map js-transpile args)))))
;; Transpile a JS expression string to SX source text (for inspection
;; in tests). Useful for asserting the exact emitted tree.
@@ -1451,7 +1451,7 @@
(fn
(src)
(let
((result (eval-expr (js-transpile (js-parse (js-tokenize src))))))
((result (eval-expr (list (quote let) (list) (js-transpile (js-parse (js-tokenize src)))))))
(js-drain-microtasks!)
result)))