js-on-sx: fn.toString honours Function.prototype.toString overrides
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 41s

Two hardcoded paths returned the native marker regardless of user
override: js-invoke-function-method and the lambda branch of
js-to-string. Both now look up Function.prototype.toString via
js-dict-get-walk and invoke it on the function, falling back to
the native marker only if no override exists.
built-ins/String: 84/99 → 85/99. conformance.sh: 148/148.
This commit is contained in:
2026-05-08 12:07:55 +00:00
parent e97bdc4602
commit d51ae65bbb
4 changed files with 36 additions and 17 deletions

View File

@@ -306,7 +306,13 @@
(fn
(&rest more)
(js-call-with-this this-arg recv (js-list-concat bound more)))))
((= key "toString") "function () { [native code] }")
((= key "toString")
(let
((override (js-dict-get-walk (get js-function-global "prototype") "toString")))
(if
(= (type-of override) "lambda")
(js-call-with-this recv override args)
"function () { [native code] }")))
((= key "name") (js-extract-fn-name recv))
((= key "length") (js-fn-length recv))
(else :js-undefined))))
@@ -1393,7 +1399,18 @@
"[object Object]"))
(js-to-string result)))
"[object Object]"))))
(if (= (type-of v) "list") (js-list-join v ",") (str v)))))))
(cond
((= (type-of v) "list") (js-list-join v ","))
((js-function? v)
(let
((tostr-fn (js-dict-get-walk (get js-function-global "prototype") "toString")))
(if
(= (type-of tostr-fn) "lambda")
(let
((result (js-call-with-this v tostr-fn ())))
(if (= (type-of result) "string") result "function () { [native code] }"))
"function () { [native code] }")))
(else (str v))))))))
(define
js-template-concat

View File

@@ -1,26 +1,26 @@
{
"totals": {
"pass": 84,
"fail": 12,
"pass": 85,
"fail": 11,
"skip": 1,
"timeout": 3,
"total": 100,
"runnable": 99,
"pass_rate": 84.8
"pass_rate": 85.9
},
"categories": [
{
"category": "built-ins/String",
"total": 100,
"pass": 84,
"fail": 12,
"pass": 85,
"fail": 11,
"skip": 1,
"timeout": 3,
"pass_rate": 84.8,
"pass_rate": 85.9,
"top_failures": [
[
"Test262Error (assertion failed)",
10
9
],
[
"Timeout",
@@ -40,7 +40,7 @@
"top_failure_modes": [
[
"Test262Error (assertion failed)",
10
9
],
[
"Timeout",
@@ -56,6 +56,6 @@
]
],
"pinned_commit": "d5e73fc8d2c663554fb72e2380a8c2bc1a318a33",
"elapsed_seconds": 192.4,
"elapsed_seconds": 182.4,
"workers": 1
}

View File

@@ -1,13 +1,13 @@
# test262 scoreboard
Pinned commit: `d5e73fc8d2c663554fb72e2380a8c2bc1a318a33`
Wall time: 192.4s
Wall time: 182.4s
**Total:** 84/99 runnable passed (84.8%). Raw: pass=84 fail=12 skip=1 timeout=3 total=100.
**Total:** 85/99 runnable passed (85.9%). Raw: pass=85 fail=11 skip=1 timeout=3 total=100.
## Top failure modes
- **10x** Test262Error (assertion failed)
- **9x** Test262Error (assertion failed)
- **3x** Timeout
- **1x** ReferenceError (undefined symbol)
- **1x** SyntaxError (parse/unsupported syntax)
@@ -16,13 +16,13 @@ Wall time: 192.4s
| Category | Pass | Fail | Skip | Timeout | Total | Pass % |
|---|---:|---:|---:|---:|---:|---:|
| built-ins/String | 84 | 12 | 1 | 3 | 100 | 84.8% |
| built-ins/String | 85 | 11 | 1 | 3 | 100 | 85.9% |
## Per-category top failures (min 10 runnable, worst first)
### built-ins/String (84/99 — 84.8%)
### built-ins/String (85/99 — 85.9%)
- **10x** Test262Error (assertion failed)
- **9x** Test262Error (assertion failed)
- **3x** Timeout
- **1x** ReferenceError (undefined symbol)
- **1x** SyntaxError (parse/unsupported syntax)