Fork me on GitHub
#clojure-dev
<
2017-10-16
>
slipset19:10:52

Seems like

slipset19:10:06

(defn foo []
  ::spec/invalid)

slipset19:10:15

is invalid in clojure-1.9-beta2

slipset19:10:52

CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/defn did not conform to spec:
In: [2] val: :clojure.spec.alpha/invalid fails spec: :clojure.core.specs.alpha/defn-args at: [:args :bs :arity-1 :body :prepost+body :prepost] predicate: map?
In: [2] val: :clojure.spec.alpha/invalid fails spec: :clojure.core.specs.alpha/defn-args at: [:args :bs :arity-1 :body :body] predicate: any?
 #:clojure.spec.alpha{:problems ({:path [:args :bs :arity-1 :body :prepost+body :prepost], :pred clojure.core/map?, :val :clojure.spec.alpha/invalid, :via [:clojure.core.specs.alpha/defn-args], :in [2]} {:path [:args :bs :arity-1 :body :body], :pred clojure.core/any?, :val :clojure.spec.alpha/invalid, :via [:clojure.core.specs.alpha/defn-args], :in [2]}), :spec #object[clojure.spec.alpha$regex_spec_impl$reify__1188 0x568c2ec6 "[email protected]"], :value (foo [] :clojure.spec.alpha/invalid), :args (foo [] :clojure.spec.alpha/invalid)}, compiling:(/Users/erik/Documents/telenordigital.com/di-data-inventory/src/data_inventory/handler.clj:41:1) 

slipset19:10:19

(defn foo []
  ::spec/foo)

favila19:10:24

::spec/invalid is a sentinel value used internally by spec. I think you're just not ever supposed to use it as a value.

favila19:10:05

(e.g. like putting nil on a core.async channel, you just can't)

hiredman19:10:27

you can work around that error with something like (defn foo [] (identity ::spec/invalid))

hiredman19:10:40

but you won't be able to spec the return value of the function

slipset19:10:07

@hiredman fair enough that I can't spec the return value, but I would like to be able to define it, I mean the function is perfectly valid as such.

hiredman19:10:31

well, it depends on what you mean by perfectly valid

hiredman19:10:59

::spec/invalid is not a valid spec value, and spec is used to verify macro expansions, so

slipset19:10:07

same goes for let btw

slipset19:10:17

(let [foo 'bar] ::spec/invalid)

hiredman19:10:35

sure, anything with macros that have specs can run in to those issues

slipset20:10:23

@favila: yes, the problem arises from

(spec/conform  any? ::spec/invalid)
;; => :clojure.spec.alpha/invalid

slipset20:10:50

which is both true and false, in a way.

seancorfield20:10:30

We have conformer functions that return ::s/invalid but you do have to be a bit careful about how/when you do so.