Uploaded image for project: 'ClojureScript'
  1. CLJS-2397

Multi-arity function instrumentation fails with :static-fns true

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Affects versions: None
    • Fix versions: None
    • Labels:
    • Environment:

      GNU/Linux

    • Patch:
      Code

      Description

      The following code, in a cljc file, will pass all tests in Clojure, as well as ClojureScript with :optimizations :none, but will fail the second assertion when :optimizations :advanced is enabled.

      (ns cljs-arity-spec-issue.core-test
        (:require #?@(:clj [[clojure.test :refer :all]
                            [clojure.spec.alpha :as s]
                            [clojure.spec.test.alpha :as st]]
      
                    :cljs [[cljs.test
                            :refer-macros [deftest testing is use-fixtures]]
                           [cljs.spec.alpha :as s]
                           [cljs.spec.test.alpha :as st]])))
      
      (defn arities
        ([a]
         (inc a))
        ([a b]
         (+ a b))
        ([a b c]
         0))
      (s/fdef arities
              :args (s/or :arity-1 (s/cat :a number?)
                          :arity-2 (s/cat :a number? :b number?)
                          :arity-3 (s/cat :a string? :b boolean? :c map?))
              :ret number?)
      
      (st/instrument)
      
      (deftest arities'
        (testing "Arity-1 Positive"
          (is (arities 1)))
        (testing "Arity-1 Negative"
          (is (thrown? #?(:clj RuntimeException :cljs :default)
                       (arities "bad"))))) ; This test fails with :advanced enabled
      

        Attachments

          Activity

            People

            • Assignee:
              mfikes Mike Fikes
              Reporter:
              alex+import import
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: