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
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user