Fork me on GitHub

seems like I hit an interesting bug: direct-linking breaking a multispec : [...] foo is not a fn, expected predicate fn


still trying to understand the why/how


:at [clojure.spec.alpha$dt invokeStatic alpha.clj 756]}]

Alex Miller (Clojure team)12:09:22

and you can’t reproduce without direct linking?


the bug goes away without dl yes

Alex Miller (Clojure team)12:09:56

well would be good to see a jira on that if you can build a reproducible case


the code is quite involved I ll try to create a minimal repro

Alex Miller (Clojure team)12:09:24

I don’t think multimethod calls are direct linked

Alex Miller (Clojure team)12:09:56

the line you have above is part of regex specs, not multispec


but it mentions a fn that's used as first arg to a multi-spec


(it's a multimethod to be more precise)

Alex Miller (Clojure team)12:09:14

sorry, just guessing from too little info


managed to get spec working on clojurescript also after some searching/trying, but did not find any direct help on the internet. I’n now using a cljc file starting with `(ns m-venue.spec (:require [#?(:clj clojure.spec.alpha :cljs cljs.spec.alpha :default clojure.spec.alpha) :as s]))` and on clojure I only need to source path, for clojurescript i need to put it in the source paths and require it. Now I can use the same spec front and back-end 🙂.

Alex Miller (Clojure team)22:09:52

cljs automatically rewrites the clojure namespace as the cljs one, so you shouldn’t actually need any of this afaik - just require the clojure ns


hi everyone, im trying to use :pre and :post to produce a more detailed error in run time

(defn person-name
  {:pre  [(if-not (s/valid? ::person person)
            (throw (IllegalArgumentException. (s/explain ::person person)))
   :post [(if-not (s/valid? string? %)
            (throw (Exception. (s/valid? string? %)))
  (str (::first-name person) " " (::last-name person)))

(person-name 42)
;;=> CompilerException java.lang.IllegalArgumentException
val: 42 fails spec: :payment-gateway.util/person predicate: map?
:clojure.spec.alpha/spec  :payment-gateway.util/person
:clojure.spec.alpha/value  42

;; works fine, s/explains works properly

(person-name {::first-name "Elon" ::last-name "Musk" ::email ""})
CompilerException java.lang.AssertionError: Assert failed: (if-not (s/valid? string? %) (throw (Exception. (s/valid? string? %))) false), compiling:(/Users/l/payment-gateway/src/payment_gateway/util.clj:31:1) 

no explain data is printed :(


missing # ?


why this works for :pre but not for :post?

Alex Miller (Clojure team)22:09:23

shouldn’t both of those pre and post be functions? I think they’re both getting evaluated at compilation time, not runtime