Welcome! Please see the About page for a little more info on how this works.

0 votes
in Spec by
Conforming a defn to the ::defn-args spec correctly preserves any type hint given to the inputs, but incorrectly loses the type hint given to the return value.


user=> (require '[clojure.spec.alpha :as s] '[clojure.core.specs.alpha :as ss])
nil
user=> (def c '(f ^double [^long x] 0.0))
#'user/c
user=> (binding [*print-meta* true] (prn c))
^{:line 10, :column 9} (f ^double [^long x] 0.0)
nil
user=> (binding [*print-meta* true] (prn (s/conform ::ss/defn-args c)))
{:name f, :bs [:arity-1 {:args {:args [[:sym ^long x]]}, :body [:body [0.0]]}]}
nil


*Cause:* Conformed regex specs do not retain meta on their conformed value (coll specs do):


user=> (binding [*print-meta* true] (prn (s/conform (s/coll-of int?) ^{:hi :there} [1])))
^{:hi :there} [1]

user=> (binding [*print-meta* true] (prn (s/conform (s/* int?) ^{:hi :there} [1])))
[1]


The particular spec where this comes up here is :clojure.core.specs.alpha/arg-list, which is an s/*.

1 Answer

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-2381 (reported by markengelberg)
...