diff --git a/src/main/clojure/cljs/core.cljc b/src/main/clojure/cljs/core.cljc index b64b2c9a3..3e1478df8 100644 --- a/src/main/clojure/cljs/core.cljc +++ b/src/main/clojure/cljs/core.cljc @@ -1507,12 +1507,13 @@ ~(with-meta `(fn ~[this-sym argsym] (this-as ~this-sym - (.apply (.-call ~this-sym) ~this-sym - (.concat (array ~this-sym) - (if (> (.-length ~argsym) ~max-ifn-arity) - (doto (.slice ~argsym 0 ~max-ifn-arity) - (.push (.slice ~argsym ~max-ifn-arity))) - ~argsym))))) + (let [args# (cljs.core/aclone ~argsym)] + (.apply (.-call ~this-sym) ~this-sym + (.concat (array ~this-sym) + (if (> (.-length args#) ~max-ifn-arity) + (doto (.slice args# 0 ~max-ifn-arity) + (.push (.slice args# ~max-ifn-arity))) + args#)))))) (meta form)))] (ifn-invoke-methods type type-sym form)))) diff --git a/src/test/cljs/cljs/apply_test.cljs b/src/test/cljs/cljs/apply_test.cljs index adcee65a6..9379ffb53 100644 --- a/src/test/cljs/cljs/apply_test.cljs +++ b/src/test/cljs/cljs/apply_test.cljs @@ -47,7 +47,10 @@ (is (= (range 22) (apply meta-f (range 22))) "Should properly call the last IFn arity with 20 args with last being a seq") (is (= (range 22) (.apply meta-f nil (to-array (range 22)))) - ".apply should also handle >20 arguments")) + ".apply should also handle >20 arguments") + (let [ctor #(.apply meta-f nil (js-arguments))] ; CLJS-3382 + (is (= '(1 2 3) (.apply ctor nil #js [1 2 3]))) + (is (= (range 30) (.apply ctor nil (to-array (range 30))))))) (deftest multi-arity-test (is (= 2 (apply (fn ([a] a) ([a b] b)) 1 [2])))