From 95fb5ef8ef2b2a2035a0c76a9e8d9cf0631ce0aa Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 7 May 2026 16:54:06 +0000 Subject: [PATCH] js-on-sx: TypeError-on-not-callable uses type-of, not (str fn-val) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Formatting wrapper dicts with (str fn-val) recursively walks the proto chain through SX inspect — for String/Number wrappers whose prototype contains lambdas this hangs. Switched the message to (type-of fn-val), e.g. "dict is not a function". Less specific but always terminates. built-ins/String: 73/99 → 75/99 (canonical). conformance.sh: 148/148. --- lib/js/runtime.sx | 2 +- lib/js/test262-scoreboard.json | 26 +++++++++++++------------- lib/js/test262-scoreboard.md | 12 ++++++------ plans/js-on-sx.md | 2 ++ 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/lib/js/runtime.sx b/lib/js/runtime.sx index 7e140484..245a45af 100644 --- a/lib/js/runtime.sx +++ b/lib/js/runtime.sx @@ -430,7 +430,7 @@ (raise (js-new-call TypeError - (list (str (str fn-val) " is not a function")))) + (list (str (type-of fn-val) " is not a function")))) (cond ((= (len args) 0) (callable)) ((= (len args) 1) (callable (nth args 0))) diff --git a/lib/js/test262-scoreboard.json b/lib/js/test262-scoreboard.json index da449e0b..4e5d6b99 100644 --- a/lib/js/test262-scoreboard.json +++ b/lib/js/test262-scoreboard.json @@ -1,33 +1,33 @@ { "totals": { - "pass": 73, - "fail": 20, + "pass": 75, + "fail": 18, "skip": 1, "timeout": 6, "total": 100, "runnable": 99, - "pass_rate": 73.7 + "pass_rate": 75.8 }, "categories": [ { "category": "built-ins/String", "total": 100, - "pass": 73, - "fail": 20, + "pass": 75, + "fail": 18, "skip": 1, "timeout": 6, - "pass_rate": 73.7, + "pass_rate": 75.8, "top_failures": [ [ "Test262Error (assertion failed)", 10 ], [ - "TypeError: not a function", - 8 + "Timeout", + 6 ], [ - "Timeout", + "TypeError: not a function", 6 ], [ @@ -47,11 +47,11 @@ 10 ], [ - "TypeError: not a function", - 8 + "Timeout", + 6 ], [ - "Timeout", + "TypeError: not a function", 6 ], [ @@ -64,6 +64,6 @@ ] ], "pinned_commit": "d5e73fc8d2c663554fb72e2380a8c2bc1a318a33", - "elapsed_seconds": 280.3, + "elapsed_seconds": 382.7, "workers": 1 } \ No newline at end of file diff --git a/lib/js/test262-scoreboard.md b/lib/js/test262-scoreboard.md index bba0ada5..d2630b43 100644 --- a/lib/js/test262-scoreboard.md +++ b/lib/js/test262-scoreboard.md @@ -1,15 +1,15 @@ # test262 scoreboard Pinned commit: `d5e73fc8d2c663554fb72e2380a8c2bc1a318a33` -Wall time: 280.3s +Wall time: 382.7s -**Total:** 73/99 runnable passed (73.7%). Raw: pass=73 fail=20 skip=1 timeout=6 total=100. +**Total:** 75/99 runnable passed (75.8%). Raw: pass=75 fail=18 skip=1 timeout=6 total=100. ## Top failure modes - **10x** Test262Error (assertion failed) -- **8x** TypeError: not a function - **6x** Timeout +- **6x** TypeError: not a function - **1x** ReferenceError (undefined symbol) - **1x** SyntaxError (parse/unsupported syntax) @@ -17,14 +17,14 @@ Wall time: 280.3s | Category | Pass | Fail | Skip | Timeout | Total | Pass % | |---|---:|---:|---:|---:|---:|---:| -| built-ins/String | 73 | 20 | 1 | 6 | 100 | 73.7% | +| built-ins/String | 75 | 18 | 1 | 6 | 100 | 75.8% | ## Per-category top failures (min 10 runnable, worst first) -### built-ins/String (73/99 — 73.7%) +### built-ins/String (75/99 — 75.8%) - **10x** Test262Error (assertion failed) -- **8x** TypeError: not a function - **6x** Timeout +- **6x** TypeError: not a function - **1x** ReferenceError (undefined symbol) - **1x** SyntaxError (parse/unsupported syntax) diff --git a/plans/js-on-sx.md b/plans/js-on-sx.md index 9c9ec155..24d7c2f8 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-07 — **`js-apply-fn` TypeError uses `type-of fn-val` not `(str fn-val)` to avoid runaway formatting.** Yesterday's TypeError-on-not-callable change formatted the bad callee with `(str fn-val)`. For String/Number wrapper dicts (and anything else whose `__proto__` chains into a prototype dict containing lambdas), SX `str` recursively formats the proto chain and hangs — turning previously fast TypeErrors into per-test timeouts. Switched to `(type-of fn-val)` (e.g. "dict is not a function"). Less specific but always terminates. built-ins/String: 73/99 → 75/99 (canonical). conformance.sh: 148/148. + - 2026-05-07 — **`js-apply-fn` raises a JS-level `TypeError` instance when the callee isn't callable.** Calling a non-callable (`'a'()`, `(1+2)()`, etc.) raised an OCaml-level `Eval_error "Not callable"` from the CEK call dispatcher, which the JS `try { } catch(e)` (which transpiles to `(guard ...)`) couldn't intercept. Added a `(js-function? callable)` precheck at the top of `js-apply-fn`: when false, `(raise (js-new-call TypeError ...))` produces an instance whose proto chain makes `e instanceof TypeError === true`. Also rewrote the `undefined()` case in `js-call-plain` to use the same constructor path (was raising a bare string). built-ins/String: 71/99 → 73/99 (canonical), 74/99 → 75/99 (isolated). conformance.sh: 148/148. - 2026-05-07 — **`js-dict-get-walk` falls back to `Object.prototype` when an object has no `__proto__`.** Object literals (`{}`, `{a:1}`) didn't carry a `__proto__` link, so `({}).toString()` couldn't find `Object.prototype.toString` — and overriding `Object.prototype.toString` had no effect on plain objects. Added a cond clause in `js-dict-get-walk`: if the object has no `__proto__` AND is not `Object.prototype` itself, walk into `Object.prototype`. Termination guaranteed because Object.prototype is the recursion base case. Now `({}).toString() === "[object Object]"`, override of `Object.prototype.toString` propagates to plain objects, and `({a:1}).hasOwnProperty('a') === true`. built-ins/String: 69/99 → 71/99 (canonical), 71/99 → 74/99 (isolated). conformance.sh: 148/148.