Welcome! Please see the About page for a little more info on how this works.

0 votes
in Errors by

If you provide a sequence instead of a vector type for the entries provided to into for creating a hash-map, the error message is misleading.

user=> (into {} '((:a 0) (:b 1))) ClassCastException clojure.lang.Keyword cannot be cast to java.util.Map$Entry clojure.lang.ATransientMap.conj (ATransientMap.java:44)

As we see, it reports the type of the first item in the entry, rather than the actual error, the type of the entry itself, which can be particularly confusing if the key in the entry is actually a valid type to be an entry:

`
user=> (into {} '((["a" 1] ["b" 2]) (["c" 3] ["d" 4])))
ClassCastException clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry clojure.lang.ATransientMap.conj (ATransientMap.java:44)

user=> (pst *e)
ClassCastException clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry

clojure.lang.ATransientMap.conj (ATransientMap.java:44)
clojure.lang.ATransientMap.conj (ATransientMap.java:17)
clojure.core/conj! (core.clj:3358)
clojure.core/conj! (core.clj:3350)
clojure.lang.PersistentList.reduce (PersistentList.java:141)
clojure.core/reduce (core.clj:6747)
clojure.core/into (core.clj:6815)

`

1 Answer

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1651 (reported by alex+import)
...