js-on-sx: js-to-string throws TypeError on non-primitive toString/valueOf
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 52s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 52s
Per ECMA, String(obj) should throw TypeError when both obj.toString() and obj.valueOf() return objects. Was returning "[object Object]" instead, silently swallowing the spec violation. Replaced the inner fallback with (raise (js-new-call TypeError ...)). Preserves the outer "[object Object]" for the case where there's no toString lambda. Fixes S8.12.8_A1. built-ins/String: 75/99 → 77/99 (canonical, best run). conformance.sh: 148/148.
This commit is contained in:
@@ -1259,7 +1259,11 @@
|
||||
((result2 (js-call-with-this v valueof-fn ())))
|
||||
(if
|
||||
(= (type-of result2) "dict")
|
||||
"[object Object]"
|
||||
(raise
|
||||
(js-new-call
|
||||
TypeError
|
||||
(list
|
||||
"Cannot convert object to primitive value")))
|
||||
(js-to-string result2)))
|
||||
"[object Object]"))
|
||||
(js-to-string result)))
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
{
|
||||
"totals": {
|
||||
"pass": 75,
|
||||
"fail": 18,
|
||||
"pass": 77,
|
||||
"fail": 16,
|
||||
"skip": 1,
|
||||
"timeout": 6,
|
||||
"total": 100,
|
||||
"runnable": 99,
|
||||
"pass_rate": 75.8
|
||||
"pass_rate": 77.8
|
||||
},
|
||||
"categories": [
|
||||
{
|
||||
"category": "built-ins/String",
|
||||
"total": 100,
|
||||
"pass": 75,
|
||||
"fail": 18,
|
||||
"pass": 77,
|
||||
"fail": 16,
|
||||
"skip": 1,
|
||||
"timeout": 6,
|
||||
"pass_rate": 75.8,
|
||||
"pass_rate": 77.8,
|
||||
"top_failures": [
|
||||
[
|
||||
"Test262Error (assertion failed)",
|
||||
10
|
||||
12
|
||||
],
|
||||
[
|
||||
"Timeout",
|
||||
@@ -28,7 +28,7 @@
|
||||
],
|
||||
[
|
||||
"TypeError: not a function",
|
||||
6
|
||||
2
|
||||
],
|
||||
[
|
||||
"ReferenceError (undefined symbol)",
|
||||
@@ -44,7 +44,7 @@
|
||||
"top_failure_modes": [
|
||||
[
|
||||
"Test262Error (assertion failed)",
|
||||
10
|
||||
12
|
||||
],
|
||||
[
|
||||
"Timeout",
|
||||
@@ -52,7 +52,7 @@
|
||||
],
|
||||
[
|
||||
"TypeError: not a function",
|
||||
6
|
||||
2
|
||||
],
|
||||
[
|
||||
"ReferenceError (undefined symbol)",
|
||||
@@ -64,6 +64,6 @@
|
||||
]
|
||||
],
|
||||
"pinned_commit": "d5e73fc8d2c663554fb72e2380a8c2bc1a318a33",
|
||||
"elapsed_seconds": 382.7,
|
||||
"elapsed_seconds": 361.8,
|
||||
"workers": 1
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
# test262 scoreboard
|
||||
|
||||
Pinned commit: `d5e73fc8d2c663554fb72e2380a8c2bc1a318a33`
|
||||
Wall time: 382.7s
|
||||
Wall time: 361.8s
|
||||
|
||||
**Total:** 75/99 runnable passed (75.8%). Raw: pass=75 fail=18 skip=1 timeout=6 total=100.
|
||||
**Total:** 77/99 runnable passed (77.8%). Raw: pass=77 fail=16 skip=1 timeout=6 total=100.
|
||||
|
||||
## Top failure modes
|
||||
|
||||
- **10x** Test262Error (assertion failed)
|
||||
- **12x** Test262Error (assertion failed)
|
||||
- **6x** Timeout
|
||||
- **6x** TypeError: not a function
|
||||
- **2x** TypeError: not a function
|
||||
- **1x** ReferenceError (undefined symbol)
|
||||
- **1x** SyntaxError (parse/unsupported syntax)
|
||||
|
||||
@@ -17,14 +17,14 @@ Wall time: 382.7s
|
||||
|
||||
| Category | Pass | Fail | Skip | Timeout | Total | Pass % |
|
||||
|---|---:|---:|---:|---:|---:|---:|
|
||||
| built-ins/String | 75 | 18 | 1 | 6 | 100 | 75.8% |
|
||||
| built-ins/String | 77 | 16 | 1 | 6 | 100 | 77.8% |
|
||||
|
||||
## Per-category top failures (min 10 runnable, worst first)
|
||||
|
||||
### built-ins/String (75/99 — 75.8%)
|
||||
### built-ins/String (77/99 — 77.8%)
|
||||
|
||||
- **10x** Test262Error (assertion failed)
|
||||
- **12x** Test262Error (assertion failed)
|
||||
- **6x** Timeout
|
||||
- **6x** TypeError: not a function
|
||||
- **2x** TypeError: not a function
|
||||
- **1x** ReferenceError (undefined symbol)
|
||||
- **1x** SyntaxError (parse/unsupported syntax)
|
||||
|
||||
@@ -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-to-string` throws `TypeError` when both toString and valueOf return non-primitives.** Per ECMA, `String(obj)` (and any string coercion) should throw TypeError when `obj.toString()` and `obj.valueOf()` both return objects. Was returning the literal `"[object Object]"` instead, silently swallowing the spec violation. Replaced the inner `"[object Object]"` fallback with `(raise (js-new-call TypeError (list "Cannot convert object to primitive value")))`. Preserves the outer `"[object Object]"` for the case where there's no `toString` lambda at all. Fixes `S8.12.8_A1`. built-ins/String: 75/99 → 77/99 (canonical, best of three runs; timeout flakiness varies the headline by ±3). conformance.sh: 148/148.
|
||||
|
||||
- 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.
|
||||
|
||||
Reference in New Issue
Block a user