js-on-sx: instanceof accepts function operands (fn instanceof Function/Object)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 44s

This commit is contained in:
2026-05-09 09:44:48 +00:00
parent 86f7a351fb
commit d145532afe
2 changed files with 14 additions and 1 deletions

View File

@@ -769,9 +769,20 @@
(fn
(obj ctor)
(cond
((not (= (type-of obj) "dict")) false)
((not (js-function? ctor))
(error "TypeError: Right-hand side of instanceof is not callable"))
((js-function? obj)
(let
((proto (js-get-ctor-proto ctor))
(fnproto (get js-function-global "prototype"))
(objproto (get Object "prototype")))
(cond
((= proto fnproto) true)
((= proto objproto) true)
((and (= (type-of obj) "dict") (contains? (keys obj) "__proto__"))
(js-instanceof-walk obj proto))
(else false))))
((not (= (type-of obj) "dict")) false)
(else
(let
((proto (js-get-ctor-proto ctor)))