js-on-sx: js-apply-fn unwraps __callable__ before invoking

This commit is contained in:
2026-04-23 23:06:24 +00:00
parent 1079004981
commit d7ad7172aa

View File

@@ -58,29 +58,32 @@
js-apply-fn js-apply-fn
(fn (fn
(fn-val args) (fn-val args)
(let
((callable (if (and (dict? fn-val) (contains? (keys fn-val) "__callable__")) (get fn-val "__callable__") fn-val)))
(cond (cond
((= (len args) 0) (fn-val)) ((= (len args) 0) (callable))
((= (len args) 1) (fn-val (nth args 0))) ((= (len args) 1) (callable (nth args 0)))
((= (len args) 2) (fn-val (nth args 0) (nth args 1))) ((= (len args) 2) (callable (nth args 0) (nth args 1)))
((= (len args) 3) (fn-val (nth args 0) (nth args 1) (nth args 2))) ((= (len args) 3)
(callable (nth args 0) (nth args 1) (nth args 2)))
((= (len args) 4) ((= (len args) 4)
(fn-val (nth args 0) (nth args 1) (nth args 2) (nth args 3))) (callable (nth args 0) (nth args 1) (nth args 2) (nth args 3)))
((= (len args) 5) ((= (len args) 5)
(fn-val (callable
(nth args 0) (nth args 0)
(nth args 1) (nth args 1)
(nth args 2) (nth args 2)
(nth args 3) (nth args 3)
(nth args 4))) (nth args 4)))
((= (len args) 6) ((= (len args) 6)
(fn-val (callable
(nth args 0) (nth args 0)
(nth args 1) (nth args 1)
(nth args 2) (nth args 2)
(nth args 3) (nth args 3)
(nth args 4) (nth args 4)
(nth args 5))) (nth args 5)))
(else (apply fn-val args))))) (else (apply callable args))))))
;; Minimal string->number for the slice. Handles integers, negatives, ;; Minimal string->number for the slice. Handles integers, negatives,
;; and simple decimals. Returns 0 on malformed input. ;; and simple decimals. Returns 0 on malformed input.