bhb / expound

Human-optimized error messages for clojure.spec
Eclipse Public License 1.0
924 stars 24 forks source link

PersistentList cannot be cast to class Named #229

Closed nikolavojicic closed 2 years ago

nikolavojicic commented 2 years ago

Repro:

(s/def ::x  string?)
(s/def ::y  int?)
(s/def ::i1 inst?)
(s/def ::i2 inst?)
(s/def ::m  (s/keys :req-un [(or ::x ::y) ::i1 ::i2]))

clojure.spec.alpha 1.11.0-alpha2

(s/explain ::m {:x 1 :y "1" :i1 #inst "2020" :i2 #inst "2020"})
;=>
1 - failed: string? in: [:x] at: [:x] spec: :user/x
"1" - failed: int? in: [:y] at: [:y] spec: :user/y

expound.alpha 0.8.10

(e/expound ::m {:x 1 :y "1" :i1 #inst "2020" :i2 #inst "2020"})
;=>
ClassCastException class clojure.lang.PersistentList cannot be cast to class clojure.lang.Named (clojure.lang.PersistentList and clojure.lang.Named are in unnamed module of loader 'app')
    clojure.core/name (core.clj:1597)
    clojure.core/name (core.clj:1591)
    expound.alpha/contains-alternate-at-path?/fn--8013 (alpha.cljc:472)
    clojure.core/map/fn--5887 (core.clj:2757)
    clojure.lang.LazySeq.sval (LazySeq.java:42)
    clojure.lang.LazySeq.seq (LazySeq.java:51)
    clojure.lang.RT.seq (RT.java:535)
    clojure.core/seq--5422 (core.clj:139)
    clojure.core/concat/cat--5515/fn--5516 (core.clj:736)
    clojure.lang.LazySeq.sval (LazySeq.java:42)
    clojure.lang.LazySeq.seq (LazySeq.java:58)
    clojure.lang.RT.seq (RT.java:535)
bhb commented 2 years ago

@nikolavojicic Thanks for reporting this!

bhb commented 2 years ago

@nikolavojicic Thanks again for the bug report. If your project can depend on specific SHAs for Expound, this is fixed in f1bb2496ba83aeeaaaa25f7461c1e3b63b7353fc .

bhb commented 2 years ago

This has been released as part of 0.9.0