Issue with spec-ing higher-order functions; clojure.lang.AFunction$1 cannot be cast to clojure.lang.MultiFn

2019-01-17 Thread Josip Gracin
Hi!

The following test throws an exception when run using "lein test" and I 
can't figure out why.

(ns issue
  (:require  [clojure.test :as t]
 [clojure.spec.alpha :as s]
 [clojure.spec.test.alpha :as st]))

(s/fdef ::boolean-supplier
  :args (s/cat)
  :ret boolean?)

(defn make-fn [boolean-supplier]
  (fn []
(boolean-supplier)))

(s/fdef make-fn
  :args (s/cat :supplier ::boolean-supplier))

(t/deftest issue
  (t/testing "issue demo"
(st/instrument)
(make-fn (fn [] true

Here's the output of "lein test":

$ lein test   
 
lein test issue
  
lein test :only issue/issue
  
   
ERROR in (issue) (Compiler.java:7647)  
Uncaught exception, not in assertion.  

expected: nil  
   
  actual: clojure.lang.Compiler$CompilerException: Syntax error compiling 
at (clojure/test/check/clojure_test.cljc:95:1).
#:clojure.error{:phase :compile-syntax-check, :line 95, :column 1, :source 
"clojure/test/check/clojure_test.cljc"}
 at clojure.lang.Compiler.load (Compiler.java:7647)
  
clojure.lang.RT.loadResourceScript (RT.java:381) 
clojure.lang.RT.loadResourceScript (RT.java:372)

clojure.lang.RT.load (RT.java:463)  
clojure.lang.RT.load (RT.java:428)
...
Caused by: java.lang.ClassCastException: clojure.lang.AFunction$1 cannot be 
cast to clojure.lang.MultiFn
 at clojure.core$get_method.invokeStatic (core.clj:1817)
clojure.core$get_method.invoke (core.clj:1817)  
   
clojure.test.check.clojure_test$eval1131.invokeStatic 
(clojure_test.cljc:95)
clojure.test.check.clojure_test$eval1131.invoke (clojure_test.cljc:95)
clojure.lang.Compiler.eval (Compiler.java:7176)
  
clojure.lang.Compiler.load (Compiler.java:7635)
...

Using Java 10.0.2 and the following dependencies:

$ lein deps :tree
 [clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
 [nrepl "0.5.3" :exclusions [[org.clojure/clojure]]]
   [nrepl/bencode "1.0.0"]
 [org.clojure/clojure "1.10.0"]
 [org.clojure/core.specs.alpha "0.2.44"]
 [org.clojure/spec.alpha "0.2.176"]
 [org.clojure/test.check "0.9.0"]

Any ideas?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue with spec-ing higher-order functions; clojure.lang.AFunction$1 cannot be cast to clojure.lang.MultiFn

2019-01-17 Thread Alex Miller
Your boolean-supplier should be:

(s/def ::boolean-supplier
  (s/fspec
:args (s/cat)
:ret boolean?))



On Thursday, January 17, 2019 at 6:38:44 AM UTC-6, Josip Gracin wrote:
>
> Hi!
>
> The following test throws an exception when run using "lein test" and I 
> can't figure out why.
>
> (ns issue
>   (:require  [clojure.test :as t]
>  [clojure.spec.alpha :as s]
>  [clojure.spec.test.alpha :as st]))
>
> (s/fdef ::boolean-supplier
>   :args (s/cat)
>   :ret boolean?)
>
> (defn make-fn [boolean-supplier]
>   (fn []
> (boolean-supplier)))
>
> (s/fdef make-fn
>   :args (s/cat :supplier ::boolean-supplier))
>
> (t/deftest issue
>   (t/testing "issue demo"
> (st/instrument)
> (make-fn (fn [] true
>
> Here's the output of "lein test":
>
> $ lein test   
>  
> lein test issue
>   
> lein test :only issue/issue
>   
>
> ERROR in (issue) (Compiler.java:7647)  
> Uncaught exception, not in assertion.  
> 
> expected: nil  
>
>   actual: clojure.lang.Compiler$CompilerException: Syntax error compiling 
> at (clojure/test/check/clojure_test.cljc:95:1).
> #:clojure.error{:phase :compile-syntax-check, :line 95, :column 1, :source 
> "clojure/test/check/clojure_test.cljc"}
>  at clojure.lang.Compiler.load (Compiler.java:7647)
>   
> clojure.lang.RT.loadResourceScript (RT.java:381) 
> clojure.lang.RT.loadResourceScript (RT.java:372)  
>   
> clojure.lang.RT.load (RT.java:463)  
> clojure.lang.RT.load (RT.java:428)
> ...
> Caused by: java.lang.ClassCastException: clojure.lang.AFunction$1 cannot 
> be cast to clojure.lang.MultiFn
>  at clojure.core$get_method.invokeStatic (core.clj:1817)
> clojure.core$get_method.invoke (core.clj:1817)
>  
> clojure.test.check.clojure_test$eval1131.invokeStatic 
> (clojure_test.cljc:95)
> clojure.test.check.clojure_test$eval1131.invoke (clojure_test.cljc:95)
> clojure.lang.Compiler.eval (Compiler.java:7176)
>   
> clojure.lang.Compiler.load (Compiler.java:7635)
> ...
>
> Using Java 10.0.2 and the following dependencies:
>
> $ lein deps :tree
>  [clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
>  [nrepl "0.5.3" :exclusions [[org.clojure/clojure]]]
>[nrepl/bencode "1.0.0"]
>  [org.clojure/clojure "1.10.0"]
>  [org.clojure/core.specs.alpha "0.2.44"]
>  [org.clojure/spec.alpha "0.2.176"]
>  [org.clojure/test.check "0.9.0"]
>
> Any ideas?
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue with spec-ing higher-order functions; clojure.lang.AFunction$1 cannot be cast to clojure.lang.MultiFn

2019-01-17 Thread Josip Gracin
Thanks!  I understand why my version is incorrect.  However, I get the same 
error with the corrected spec.

On Thursday, January 17, 2019 at 3:26:24 PM UTC+1, Alex Miller wrote:
>
> Your boolean-supplier should be:
>
> (s/def ::boolean-supplier
>   (s/fspec
> :args (s/cat)
> :ret boolean?))
>
>
>
> On Thursday, January 17, 2019 at 6:38:44 AM UTC-6, Josip Gracin wrote:
>>
>> Hi!
>>
>> The following test throws an exception when run using "lein test" and I 
>> can't figure out why.
>>
>> (ns issue
>>   (:require  [clojure.test :as t]
>>  [clojure.spec.alpha :as s]
>>  [clojure.spec.test.alpha :as st]))
>>
>> (s/fdef ::boolean-supplier
>>   :args (s/cat)
>>   :ret boolean?)
>>
>> (defn make-fn [boolean-supplier]
>>   (fn []
>> (boolean-supplier)))
>>
>> (s/fdef make-fn
>>   :args (s/cat :supplier ::boolean-supplier))
>>
>> (t/deftest issue
>>   (t/testing "issue demo"
>> (st/instrument)
>> (make-fn (fn [] true
>>
>> Here's the output of "lein test":
>>
>> $ lein test   
>>  
>> lein test issue
>>   
>> lein test :only issue/issue  
>> 
>>
>> ERROR in (issue) (Compiler.java:7647)  
>> Uncaught exception, not in assertion.
>>   
>> expected: nil
>>  
>>   actual: clojure.lang.Compiler$CompilerException: Syntax error compiling 
>> at (clojure/test/check/clojure_test.cljc:95:1).
>> #:clojure.error{:phase :compile-syntax-check, :line 95, :column 1, 
>> :source "clojure/test/check/clojure_test.cljc"}
>>  at clojure.lang.Compiler.load (Compiler.java:7647)  
>> 
>> clojure.lang.RT.loadResourceScript (RT.java:381) 
>> clojure.lang.RT.loadResourceScript (RT.java:372)  
>>   
>> clojure.lang.RT.load (RT.java:463)  
>> clojure.lang.RT.load (RT.java:428)
>> ...
>> Caused by: java.lang.ClassCastException: clojure.lang.AFunction$1 cannot 
>> be cast to clojure.lang.MultiFn
>>  at clojure.core$get_method.invokeStatic (core.clj:1817)
>> clojure.core$get_method.invoke (core.clj:1817)
>>  
>> clojure.test.check.clojure_test$eval1131.invokeStatic 
>> (clojure_test.cljc:95)
>> clojure.test.check.clojure_test$eval1131.invoke (clojure_test.cljc:95)
>> clojure.lang.Compiler.eval (Compiler.java:7176)  
>> 
>> clojure.lang.Compiler.load (Compiler.java:7635)
>> ...
>>
>> Using Java 10.0.2 and the following dependencies:
>>
>> $ lein deps :tree
>>  [clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
>>  [nrepl "0.5.3" :exclusions [[org.clojure/clojure]]]
>>[nrepl/bencode "1.0.0"]
>>  [org.clojure/clojure "1.10.0"]
>>  [org.clojure/core.specs.alpha "0.2.44"]
>>  [org.clojure/spec.alpha "0.2.176"]
>>  [org.clojure/test.check "0.9.0"]
>>
>> Any ideas?
>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue with spec-ing higher-order functions; clojure.lang.AFunction$1 cannot be cast to clojure.lang.MultiFn

2019-01-17 Thread Alex Miller
The modified version works for me, so not sure what you're seeing.

$ clj
Clojure 1.10.0
user=>
(ns issue
  (:require  [clojure.test :as t]
 [clojure.spec.alpha :as s]
 [clojure.spec.test.alpha :as st]))
nil

issue=>
(s/def ::boolean-supplier
  (s/fspec
:args (s/cat)
:ret boolean?))
:issue/boolean-supplier

issue=>
(defn make-fn [boolean-supplier]
  (fn []
(boolean-supplier)))
#'issue/make-fn

issue=>
(s/fdef make-fn
  :args (s/cat :supplier ::boolean-supplier))
issue/make-fn

issue=>
(t/deftest issue
  (t/testing "issue demo"
(st/instrument)
(make-fn (fn [] true
#'issue/issue

issue=> (issue)
nil



On Thu, Jan 17, 2019 at 9:09 AM Josip Gracin  wrote:

> Thanks!  I understand why my version is incorrect.  However, I get the
> same error with the corrected spec.
>
> On Thursday, January 17, 2019 at 3:26:24 PM UTC+1, Alex Miller wrote:
>>
>> Your boolean-supplier should be:
>>
>> (s/def ::boolean-supplier
>>   (s/fspec
>> :args (s/cat)
>> :ret boolean?))
>>
>>
>>
>> On Thursday, January 17, 2019 at 6:38:44 AM UTC-6, Josip Gracin wrote:
>>>
>>> Hi!
>>>
>>> The following test throws an exception when run using "lein test" and I
>>> can't figure out why.
>>>
>>> (ns issue
>>>   (:require  [clojure.test :as t]
>>>  [clojure.spec.alpha :as s]
>>>  [clojure.spec.test.alpha :as st]))
>>>
>>> (s/fdef ::boolean-supplier
>>>   :args (s/cat)
>>>   :ret boolean?)
>>>
>>> (defn make-fn [boolean-supplier]
>>>   (fn []
>>> (boolean-supplier)))
>>>
>>> (s/fdef make-fn
>>>   :args (s/cat :supplier ::boolean-supplier))
>>>
>>> (t/deftest issue
>>>   (t/testing "issue demo"
>>> (st/instrument)
>>> (make-fn (fn [] true
>>>
>>> Here's the output of "lein test":
>>>
>>> $ lein test
>>>
>>> lein test issue
>>>
>>> lein test :only issue/issue
>>>
>>>
>>> ERROR in (issue) (Compiler.java:7647)
>>> Uncaught exception, not in assertion.
>>>
>>> expected: nil
>>>
>>>   actual: clojure.lang.Compiler$CompilerException: Syntax error
>>> compiling at (clojure/test/check/clojure_test.cljc:95:1).
>>> #:clojure.error{:phase :compile-syntax-check, :line 95, :column 1,
>>> :source "clojure/test/check/clojure_test.cljc"}
>>>  at clojure.lang.Compiler.load (Compiler.java:7647)
>>>
>>> clojure.lang.RT.loadResourceScript (RT.java:381)
>>> clojure.lang.RT.loadResourceScript (RT.java:372)
>>>
>>> clojure.lang.RT.load (RT.java:463)
>>> clojure.lang.RT.load (RT.java:428)
>>> ...
>>> Caused by: java.lang.ClassCastException: clojure.lang.AFunction$1 cannot
>>> be cast to clojure.lang.MultiFn
>>>  at clojure.core$get_method.invokeStatic (core.clj:1817)
>>> clojure.core$get_method.invoke (core.clj:1817)
>>>
>>> clojure.test.check.clojure_test$eval1131.invokeStatic
>>> (clojure_test.cljc:95)
>>> clojure.test.check.clojure_test$eval1131.invoke
>>> (clojure_test.cljc:95)
>>> clojure.lang.Compiler.eval (Compiler.java:7176)
>>>
>>> clojure.lang.Compiler.load (Compiler.java:7635)
>>> ...
>>>
>>> Using Java 10.0.2 and the following dependencies:
>>>
>>> $ lein deps :tree
>>>  [clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
>>>  [nrepl "0.5.3" :exclusions [[org.clojure/clojure]]]
>>>[nrepl/bencode "1.0.0"]
>>>  [org.clojure/clojure "1.10.0"]
>>>  [org.clojure/core.specs.alpha "0.2.44"]
>>>  [org.clojure/spec.alpha "0.2.176"]
>>>  [org.clojure/test.check "0.9.0"]
>>>
>>> Any ideas?
>>>
>>> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/EkAgPjrree0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue with spec-ing higher-order functions; clojure.lang.AFunction$1 cannot be cast to clojure.lang.MultiFn

2019-01-17 Thread Josip Gracin
Thanks!  I've created an issue in Leiningen tracker
(https://github.com/technomancy/leiningen/issues/2524) because it
might have to do with it.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.