Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid arity error while using cljs.test/are with large number of args #187

Closed
logseq-cldwalker opened this issue May 10, 2022 · 12 comments

Comments

@logseq-cldwalker
Copy link
Contributor

Hi @borkdude. Encountered this curious error while trying to run some logseq tests under nbb. Any ideas what's going? I got a minimal repro


version

Latest, 0.3.97

platform

osx with node 16.13.1

problem

I'm trying to convert these tests to run under nbb. I encountered an arbitrary limit of args to are that stops working - 22

repro

In example_runner.cljs

(ns example-runner
  (:require
   [cljs.test :as t :refer [deftest are]]))

(deftest are-test
  (are [x y] (= x y)
       2 (inc 1)
       2 (inc 1)
       2 (inc 1)
       2 (inc 1)
       2 (inc 1)
       2 (inc 1)
       2 (inc 1)
       2 (inc 1)
       2 (inc 1)))

;; set exit code based on failing tests
(defmethod cljs.test/report [:cljs.test/default :end-run-tests] [m]
  (when-not (cljs.test/successful? m)
    (set! (.-exitCode js/process) 1)))

;; run this function with: nbb -m example-runner/run-tests
(defn run-tests []
  (t/run-tests 'example-runner))

Run tests to see failure:

$ nbb -m example-runner/run-tests
----- Error --------------------------------------
Message:  Invalid arity: 22
Location: /Users/me/code/work/logseq/example_runner.cljs:6:3

----- Context ------------------------------------
2:   (:require
3:    [cljs.test :as t :refer [deftest are]]))
4:
5: (deftest are-test
6:   (are [x y] (= x y)
      ^--- Invalid arity: 22
...

Comment out one of the are arg lines and see the test pass

expected behavior

I expected these tests to pass like they do in cljs

@borkdude
Copy link
Collaborator

Could be related to: clojure/clojurescript@8b3ce24 ?

@borkdude
Copy link
Collaborator

@logseq-cldwalker I had a similar issue here:

babashka/sci#603

@borkdude
Copy link
Collaborator

Yep, it looks related to that. I hope CLJS can be bumped soon, then I can also get rid of the workarounds in the before mentioned issue.

@logseq-cldwalker
Copy link
Contributor Author

logseq-cldwalker commented May 10, 2022 via email

@logseq-cldwalker
Copy link
Contributor Author

logseq-cldwalker commented May 10, 2022 via email

@borkdude
Copy link
Collaborator

Unfortunately with the newest CLJS it didn't work:

thheller/shadow-cljs {:mvn/version "2.18.0"}
        com.google.javascript/closure-compiler-unshaded {:mvn/version "v20220301"}
        org.clojure/clojurescript {:git/url "https://github.com/clojure/clojurescript"
                                   :git/sha "91c597d99b3480c0463b3648016e4f27b0b0b018"}

@borkdude
Copy link
Collaborator

I'll take a deeper look tomorrow.

@borkdude
Copy link
Collaborator

Smallest repro possible:

(defmacro foo [& xs]
  (count xs))

(prn (foo 0 1 2 3 4 5 6 7 8 9
          0 1 2 3 4 5 6 7)) ;; 18

#_(prn (foo 0 1 2 3 4 5 6 7 8 9
          0 1 2 3 4 5 6 7 8)) ;; 8 is not seqable

(prn (foo 0 1 2 3 4 5 6 7 8 9
          0 1 2 3 4 5 6 7 8 9)) ;; invalid arity 22

@borkdude
Copy link
Collaborator

Got a pure CLJS repro and posted it in the cljs-dev channel:

(def foo (with-meta (fn [& xs] (count xs))
           {:awesome true}))

(prn (satisfies? MetaFn foo)) ;; true

(prn (foo 1 2 3 4 5 6 7 9 10 11 12 13 14 15 16 17 18 19 20 21 22)) ;; 22 is not ISeqable
(prn (foo 1 2 3 4 5 6 7 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23)) ;; Invalid arity 22

@borkdude
Copy link
Collaborator

Fixed using a workaround.

@logseq-cldwalker
Copy link
Contributor Author

Thanks for finding the root cause and a workaround! ❤️

@logseq-cldwalker
Copy link
Contributor Author

Confirmed this fix worked for the original test file with latest nbb-logseq. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants