ClojureScript

High-arity .apply on spec-instrumented function throws "Invalid arity" error

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    ClojureScript 1.10.238

Description

With ClojureScript 1.10.238, if you call .apply with over 21 arguments on a function that has been instrumented with cljs.spec.test.alpha/instrument, you will get an error about invalid arity. This problem does not occur with ClojureScript 1.9.954.

(require '[cljs.spec.alpha :as s] '[cljs.spec.test.alpha :as stest])

(defn my-fun [& args] (prn :args args))
(s/fdef my-fun :args (s/cat :args (s/* any?)))

(.apply my-fun nil (into-array (range 22)))
;; :args (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)

(stest/instrument)
(.apply my-fun nil (into-array (range 22)))
;; Error: Invalid arity: 22
;;     at Function.G__10112 [as call] (.../cljs/core.js:6798:7)
;;     at Function.cljs.core.MetaFn.apply (.../cljs/core.js:6829:24)
;;     at repl:1:96

Regular apply works as expected.

Activity

Hide
David Nolen added a comment -
Show
David Nolen added a comment - See CLJS-364 & CLJS-365
Hide
A. R added a comment -

Some of these are (commented out) but added in the patch for the apply test suit: CLJS-2147

Show
A. R added a comment - Some of these are (commented out) but added in the patch for the apply test suit: CLJS-2147
Hide
David Nolen added a comment -

Ah great, thanks for the tests.

Show
David Nolen added a comment - Ah great, thanks for the tests.
David Nolen made changes -
Field Original Value New Value
Priority Major [ 3 ] Critical [ 2 ]
Hide
David Nolen added a comment -

Revisiting this now that I'm working on CLJS-2761, why do we need to support `.apply`? I don't think this was ever promised.

Show
David Nolen added a comment - Revisiting this now that I'm working on CLJS-2761, why do we need to support `.apply`? I don't think this was ever promised.
David Nolen made changes -
Priority Critical [ 2 ] Major [ 3 ]

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated: