Midje
Midje copied to clipboard
Problem with clojure.walk and metaconstants
see following case
(defn simple-walk "does nothing"
[m]
(clojure.walk/postwalk
(fn [x] x)
m))
(facts "about `simple-walk`"
(fact "with simple map, returns the map"
(simple-walk {:this "works"}) => {:this "works"})
(fact "simple map with metaconstant throws java.lang.ClassCastException"
(simple-walk {:a ..something..}) => (throws java.lang.ClassCastException)))
the exception: java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IPersistentCollection
Hey @ayrtonsin, thanks for reporting this. It looks like a duplicate of https://github.com/marick/Midje/issues/267, which we closed on accident (it hasn't been resolved yet).
I described the underlying issue here:
the postwalk example still doesn't run because the postwalk will do a
(into (empty ..a..) (map identity ..a..))
which will reduce to(conj {} ..a..)
and subsequently{}
due to ambiguous semantics of merging a partially-defined map (metaconstant) with a concrete map
I'm not really sure how to fix this yet, so it might be a while before it gets resolved, but I think it is worth thinking about more.