Skip to content

Instantly share code, notes, and snippets.

@bhb
Created September 7, 2018 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhb/1948bfca870fbc8758b515a4d0acc5ff to your computer and use it in GitHub Desktop.
Save bhb/1948bfca870fbc8758b515a4d0acc5ff to your computer and use it in GitHub Desktop.
Changing s/*explain-out* to control spec errors during macro-expansion
(require '[clojure.spec.alpha :as s])
(set! s/*explain-out* (fn [ed] (println "failed")))
(let [x] 1)
;; with org.clojure/spec.alpha {:mvn/version "0.2.168"} :
;; CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/let did not conform to spec:
;; failed
;; #:clojure.spec.alpha{:problems [{:path [:args :bindings :init-expr], :reason "Insufficient input", :pred clojure.core/any?, :val (), :via [:clojure.core.specs.alpha/bindings :clojure.core.specs.alpha/bindings], :in [0]}], :spec #object[clojure.spec.alpha$regex_spec_impl$reify__2499 0x749c877b "clojure.spec.alpha$regex_spec_impl$reify__2499@749c877b"], :value ([x] 1), :args ([x] 1)}, compiling:(NO_SOURCE_PATH:3:1)
;; with org.clojure/spec.alpha {:mvn/version "0.2.176"} :
;; CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/let did not conform to spec. #:clojure.spec.alpha{:problems [{:path [:bindings :init-expr], :reason "Insufficient input", :pred clojure.core/any?, :val (), :via [:clojure.core.specs.alpha/bindings :clojure.core.specs.alpha/bindings], :in [0]}], :spec #object[clojure.spec.alpha$regex_spec_impl$reify__2509 0x55b5f5d2 "clojure.spec.alpha$regex_spec_impl$reify__2509@55b5f5d2"], :value ([x] 1), :args ([x] 1)}, compiling:(NO_SOURCE_PATH:3:1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment