js-on-sx: Function.prototype.bind throws TypeError on non-callable target
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s

This commit is contained in:
2026-05-09 13:41:25 +00:00
parent 16e21ef6fa
commit 699b30ed1b
2 changed files with 16 additions and 10 deletions

View File

@@ -354,16 +354,20 @@
(if (or (js-undefined? raw-this) (= raw-this nil)) js-global-this raw-this)))
(js-call-with-this this-arg recv rest))))
((= key "bind")
(let
((this-arg (if (< (len args) 1) :js-undefined (nth args 0)))
(bound
(if
(< (len args) 1)
(list)
(js-list-slice args 1 (len args)))))
(fn
(&rest more)
(js-call-with-this this-arg recv (js-list-concat bound more)))))
(cond
((not (js-function? recv))
(raise (js-new-call TypeError (js-args "Function.prototype.bind: target is not callable"))))
(else
(let
((this-arg (if (< (len args) 1) :js-undefined (nth args 0)))
(bound
(if
(< (len args) 1)
(list)
(js-list-slice args 1 (len args)))))
(fn
(&rest more)
(js-call-with-this this-arg recv (js-list-concat bound more)))))))
((= key "toString")
(let
((override (js-dict-get-walk (get js-function-global "prototype") "toString")))