js-on-sx: global eval(src) actually evaluates the source
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 51s
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user