js-on-sx: new <non-callable> throws TypeError instead of hanging
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s

new (new Object("")) hung because js-new-call called
js-get-ctor-proto -> js-ctor-id -> inspect, and inspect on a
wrapper-with-proto-chain recurses through the prototype's
lambdas forever. Added (js-function? ctor) precheck at the top
of js-new-call that raises a TypeError instance instead.
conformance.sh: 148/148.
This commit is contained in:
2026-05-08 07:17:44 +00:00
parent bfec2a4320
commit 1b7bb5ad1f
4 changed files with 58 additions and 52 deletions

View File

@@ -683,18 +683,22 @@
js-new-call
(fn
(ctor args)
(let
((obj (dict)))
(begin
(dict-set! obj "__proto__" (js-get-ctor-proto ctor))
(cond
((not (js-function? ctor))
(raise (js-new-call TypeError (list (str (type-of ctor) " is not a constructor")))))
(else
(let
((ret (js-call-with-this obj ctor args)))
(if
(and
(not (js-undefined? ret))
(or (= (type-of ret) "dict") (= (type-of ret) "list") (js-function? ret)))
ret
obj))))))
((obj (dict)))
(begin
(dict-set! obj "__proto__" (js-get-ctor-proto ctor))
(let
((ret (js-call-with-this obj ctor args)))
(if
(and
(not (js-undefined? ret))
(or (= (type-of ret) "dict") (= (type-of ret) "list") (js-function? ret)))
ret
obj))))))))
;; Setter — mutates the dict. Returns the new value (JS assignment yields rhs).
(define

View File

@@ -1,37 +1,37 @@
{
"totals": {
"pass": 80,
"fail": 13,
"skip": 1,
"timeout": 6,
"total": 100,
"runnable": 99,
"pass_rate": 80.8
"pass": 23,
"fail": 20,
"skip": 5,
"timeout": 2,
"total": 50,
"runnable": 45,
"pass_rate": 51.1
},
"categories": [
{
"category": "built-ins/String",
"total": 100,
"pass": 80,
"fail": 13,
"skip": 1,
"timeout": 6,
"pass_rate": 80.8,
"category": "built-ins/Array",
"total": 50,
"pass": 23,
"fail": 20,
"skip": 5,
"timeout": 2,
"pass_rate": 51.1,
"top_failures": [
[
"Test262Error (assertion failed)",
11
17
],
[
"TypeError: not a function",
2
],
[
"Timeout",
6
2
],
[
"ReferenceError (undefined symbol)",
1
],
[
"SyntaxError (parse/unsupported syntax)",
"Unhandled: Not callable: {:2 43 :1 42 :0 41 :length 3}\\",
1
]
]
@@ -40,22 +40,22 @@
"top_failure_modes": [
[
"Test262Error (assertion failed)",
11
17
],
[
"TypeError: not a function",
2
],
[
"Timeout",
6
2
],
[
"ReferenceError (undefined symbol)",
1
],
[
"SyntaxError (parse/unsupported syntax)",
"Unhandled: Not callable: {:2 43 :1 42 :0 41 :length 3}\\",
1
]
],
"pinned_commit": "d5e73fc8d2c663554fb72e2380a8c2bc1a318a33",
"elapsed_seconds": 154.6,
"elapsed_seconds": 160.3,
"workers": 1
}

View File

@@ -1,28 +1,28 @@
# test262 scoreboard
Pinned commit: `d5e73fc8d2c663554fb72e2380a8c2bc1a318a33`
Wall time: 154.6s
Wall time: 160.3s
**Total:** 80/99 runnable passed (80.8%). Raw: pass=80 fail=13 skip=1 timeout=6 total=100.
**Total:** 23/45 runnable passed (51.1%). Raw: pass=23 fail=20 skip=5 timeout=2 total=50.
## Top failure modes
- **11x** Test262Error (assertion failed)
- **6x** Timeout
- **1x** ReferenceError (undefined symbol)
- **1x** SyntaxError (parse/unsupported syntax)
- **17x** Test262Error (assertion failed)
- **2x** TypeError: not a function
- **2x** Timeout
- **1x** Unhandled: Not callable: {:2 43 :1 42 :0 41 :length 3}\
## Categories (worst pass-rate first, min 10 runnable)
| Category | Pass | Fail | Skip | Timeout | Total | Pass % |
|---|---:|---:|---:|---:|---:|---:|
| built-ins/String | 80 | 13 | 1 | 6 | 100 | 80.8% |
| built-ins/Array | 23 | 20 | 5 | 2 | 50 | 51.1% |
## Per-category top failures (min 10 runnable, worst first)
### built-ins/String (80/99 — 80.8%)
### built-ins/Array (23/45 — 51.1%)
- **11x** Test262Error (assertion failed)
- **6x** Timeout
- **1x** ReferenceError (undefined symbol)
- **1x** SyntaxError (parse/unsupported syntax)
- **17x** Test262Error (assertion failed)
- **2x** TypeError: not a function
- **2x** Timeout
- **1x** Unhandled: Not callable: {:2 43 :1 42 :0 41 :length 3}\

View File

@@ -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 — **`new <non-callable>` 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.
- 2026-05-08 — **Lowered array padding bail-out from 2^32-1 to 1M.** Yesterday's 2^32-1 threshold still allowed indices like `2147483648` to pad billions of `js-undefined` entries, hanging the worker. Without sparse-array support there's no semantic value in supporting >1M sparse padding; lowering the bail to 1M turns those tests into fast assertion failures instead of timeouts. Removes another timeout (Array 7→1). built-ins/Array stays at 23/45, but the run is faster and no longer wall-time-bound. conformance.sh: 148/148.