diff --git a/lib/js/runtime.sx b/lib/js/runtime.sx index 868c96a6..4f5ab10e 100644 --- a/lib/js/runtime.sx +++ b/lib/js/runtime.sx @@ -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 diff --git a/lib/js/test262-scoreboard.json b/lib/js/test262-scoreboard.json index eac3ecdf..189b91ed 100644 --- a/lib/js/test262-scoreboard.json +++ b/lib/js/test262-scoreboard.json @@ -1,37 +1,37 @@ { "totals": { - "pass": 23, - "fail": 20, - "skip": 5, - "timeout": 2, - "total": 50, - "runnable": 45, - "pass_rate": 51.1 + "pass": 80, + "fail": 11, + "skip": 1, + "timeout": 8, + "total": 100, + "runnable": 99, + "pass_rate": 80.8 }, "categories": [ { - "category": "built-ins/Array", - "total": 50, - "pass": 23, - "fail": 20, - "skip": 5, - "timeout": 2, - "pass_rate": 51.1, + "category": "built-ins/String", + "total": 100, + "pass": 80, + "fail": 11, + "skip": 1, + "timeout": 8, + "pass_rate": 80.8, "top_failures": [ [ "Test262Error (assertion failed)", - 17 - ], - [ - "TypeError: not a function", - 2 + 9 ], [ "Timeout", - 2 + 8 ], [ - "Unhandled: Not callable: {:2 43 :1 42 :0 41 :length 3}\\", + "ReferenceError (undefined symbol)", + 1 + ], + [ + "SyntaxError (parse/unsupported syntax)", 1 ] ] @@ -40,22 +40,22 @@ "top_failure_modes": [ [ "Test262Error (assertion failed)", - 17 - ], - [ - "TypeError: not a function", - 2 + 9 ], [ "Timeout", - 2 + 8 ], [ - "Unhandled: Not callable: {:2 43 :1 42 :0 41 :length 3}\\", + "ReferenceError (undefined symbol)", + 1 + ], + [ + "SyntaxError (parse/unsupported syntax)", 1 ] ], "pinned_commit": "d5e73fc8d2c663554fb72e2380a8c2bc1a318a33", - "elapsed_seconds": 160.3, + "elapsed_seconds": 507.4, "workers": 1 } \ No newline at end of file diff --git a/lib/js/test262-scoreboard.md b/lib/js/test262-scoreboard.md index de9f9937..80a87868 100644 --- a/lib/js/test262-scoreboard.md +++ b/lib/js/test262-scoreboard.md @@ -1,28 +1,28 @@ # test262 scoreboard Pinned commit: `d5e73fc8d2c663554fb72e2380a8c2bc1a318a33` -Wall time: 160.3s +Wall time: 507.4s -**Total:** 23/45 runnable passed (51.1%). Raw: pass=23 fail=20 skip=5 timeout=2 total=50. +**Total:** 80/99 runnable passed (80.8%). Raw: pass=80 fail=11 skip=1 timeout=8 total=100. ## Top failure modes -- **17x** Test262Error (assertion failed) -- **2x** TypeError: not a function -- **2x** Timeout -- **1x** Unhandled: Not callable: {:2 43 :1 42 :0 41 :length 3}\ +- **9x** Test262Error (assertion failed) +- **8x** Timeout +- **1x** ReferenceError (undefined symbol) +- **1x** SyntaxError (parse/unsupported syntax) ## Categories (worst pass-rate first, min 10 runnable) | Category | Pass | Fail | Skip | Timeout | Total | Pass % | |---|---:|---:|---:|---:|---:|---:| -| built-ins/Array | 23 | 20 | 5 | 2 | 50 | 51.1% | +| built-ins/String | 80 | 11 | 1 | 8 | 100 | 80.8% | ## Per-category top failures (min 10 runnable, worst first) -### built-ins/Array (23/45 — 51.1%) +### built-ins/String (80/99 — 80.8%) -- **17x** Test262Error (assertion failed) -- **2x** TypeError: not a function -- **2x** Timeout -- **1x** Unhandled: Not callable: {:2 43 :1 42 :0 41 :length 3}\ +- **9x** Test262Error (assertion failed) +- **8x** Timeout +- **1x** ReferenceError (undefined symbol) +- **1x** SyntaxError (parse/unsupported syntax) diff --git a/plans/js-on-sx.md b/plans/js-on-sx.md index dc2f7f0f..90bad617 100644 --- a/plans/js-on-sx.md +++ b/plans/js-on-sx.md @@ -158,6 +158,8 @@ Each item: implement → tests → update progress. Mark `[x]` when tests green. Append-only record of completed iterations. Loop writes one line per iteration: date, what was done, test count delta. +- 2026-05-08 — **Global `eval(src)` actually evaluates the source.** Was returning the input string unchanged: `eval('1+2')` returned `"1+2"`, not `3`. Per spec, `eval(string)` parses and evaluates as JS; non-string input passes through. Wired the runtime stub through `js-eval` (which already does the lex/parse/transpile/eval pipeline) when the arg is a string. Fixes `String(eval('var x'))`, the harness internal `eval(...)`, and any test that calls `eval` for runtime evaluation. built-ins/String fail count: 13 → 11. conformance.sh: 148/148. + - 2026-05-08 — **`new ` throws TypeError instead of hanging.** `new (new Object(""))` (calling `new` on a String wrapper dict) hung because `js-new-call` called `js-get-ctor-proto` which fell through to `js-ctor-id` which called `inspect ctor` — and `inspect` on a wrapper-with-proto-chain recurses through the prototype's lambdas forever. Added a `(js-function? ctor)` precheck at the top of `js-new-call`: when the receiver isn't callable, raise a `TypeError` instance instead. Now `try { new x } catch(e) { e instanceof TypeError }` returns `true` for non-callable `x`. conformance.sh: 148/148. String 80/99, Array 23/45 maintained. - 2026-05-08 — **JS functions accept extra args silently (per spec).** SX strictly arity-checks: `(fn (a) ...)` rejects 2 args, but JS allows passing more args than declared (the extras are accessible via `arguments`). Was raising `f expects 1 args, got 2` whenever Array.from passed `(value, index)` to a 1-arg mapFn, etc. Fixed in `js-build-param-list` (transpile.sx): every JS function param list now ends with `&rest __extra_args__` (unless an explicit rest param is already present), so extras are silently absorbed. Headline scoreboards unchanged but unblocks a class of harness-mediated failures. conformance.sh: 148/148.