js-on-sx: global eval(src) actually evaluates the source
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 51s

Was returning the input unchanged: eval('1+2') gave "1+2".
Per spec, eval(string) parses and evaluates as JS; non-string
passes through. Wired through js-eval (existing
lex/parse/transpile/eval pipeline).
built-ins/String fail count 13 → 11. conformance.sh: 148/148.
This commit is contained in:
2026-05-08 08:44:34 +00:00
parent 1b7bb5ad1f
commit 7a898567e4
4 changed files with 48 additions and 42 deletions

View File

@@ -37,7 +37,11 @@
;; per JS (technically ToNumber("") === 0).
(define
js-global-eval
(fn (&rest args) (if (empty? args) :js-undefined (nth args 0))))
(fn (&rest args)
(cond
((empty? args) :js-undefined)
((not (= (type-of (nth args 0)) "string")) (nth args 0))
(else (js-eval (nth args 0))))))
;; Safe number-parser. Tries to call an SX primitive that can parse
;; strings to numbers; on failure returns 0 (stand-in for NaN so the