Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 797 Bytes

duplicate-case-test-constant.md

File metadata and controls

41 lines (29 loc) · 797 Bytes

Creating multiple overloads of a function with the same arity

Error message

Duplicate case test constant '1'
Error: Duplicate case test constant '1'

Cause

The above error happens when you declare two overloads of a function with the same arity.

For example, let's say we have the following function:

(defn twice
  ([x] (twice x false))
  ([x log?]
    (when log? (println "Doubling" x))
    (+ x x)))

We decide we no longer want to support the second param, but we forget to remove the first overload:

(defn twice 
  ([x] (twice x)) 
  ([x] (+ x x)))

This will result in the error above.

Solutions

Delete one of the two duplicate overloads. In our example above, our function would become:

(defn twice [x] 
  (+ x x))