Fork me on GitHub

@borkdude maybe something ugly as this would work:

(let [hash-map0 (var-get #'hash-map)]
  (alter-var-root #'clojure.core/hash-map (constantly (fn [& x] 
    (with-redefs [clojure.core/hash-map hash-map0]
      ;; validation here?
      (apply clojure.core/hash-map x)


@jeroenvandijk if you’re interested, I have a potential fix for hash-map not being able to be instrumented here:


I’ll probably give up on it for now. CLJS has plenty of similar issues like this (instrumenting apply, seq, etc.)


I’m not sure what your solution accomplishes, but you could add it to the issue with some context


From what I understand, hash-map calls hash-map itself when instrumented. So I thought of aliasing hash-map to the old version of hash-map during the validation itself. Just an idea, maybe it's shortsighted


right. the spec-checking-fn replacing hash-map calls itself (because binding emits a call to hash-map), so it ends up in a loop.


Maybe a complete clojure.core fix would be to have (stest/instrument x) to have x to be aliased to it's previous value so it cannot interfere with the instrumentation itself when x is used for the instrumentation.


that would be the more fundamental solution yes


it would also speed up core instrumentation probably


Hi. I'm experimenting with Spec. I think I'm approaching it (incorrectly) from an OO background. Suppose I have a spec ::vehicle #{:car :truck :semi-truck :bicycle :motorbike}. It is part of a map (s/keys :req [::vehicle ::color]). At some time later in processing, I have a function that requires 2-wheeled vehicles, so I might have ::two-wheeled-vehicle (s/and ::car has-two-wheels?). My problem is I've already used the ::vehicle key for the more "generic" specification of a vehicle. I would need to create a new map with new keys (`(s/keys :req [::two-wheeled-vehicle ::color])`), and copy all the values over, in order to validate the stricter specification. Am I doing it wrong?