Hi Travis,

As you noticed, there is no error handling for the case where you pass a bad 
spec to defrecord. In your example, the spec has method bodies but no 
protocol-or-interface-or-Object.

I have created a ticket for this at 
https://www.assembla.com/spaces/clojure/tickets/405-better-error-messages-for-bad-defrecord-calls.

The ticket comment includes instructions for how and where to patch this. If 
anyone has been frustrated by Clojure's error messages and is looking for an 
easy way to contribute, have at it. :-)

Stu

> Hello, I've come across the following compiler error in defrecord and
> deftype:
> 
> java.lang.RuntimeException: java.lang.ClassCastException:
> clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
> (test.clj:0)
> 
> To generate the error, evaluate the following code:
> 
> (ns test)
> 
> (defrecord TestRecord [afield bfield cfield]
>  (printc [_] (println cfield)))
> 
> (deftype TestType [afield bfield cfield]
>  (printc [_] (println cfield)))
> 
> The error I believe I should be getting is something like this:
> 
> java.lang.IllegalArgumentException: Can't define method not in
> interfaces: printc (test.clj:8)
> 
> Which can be generated with the following code:
> 
> (ns test)
> 
> (defprotocol TestProtocol
>  ""
>  (printa [testtype] "")
>  (printb [testtype] ""))
> 
> (defrecord TestRecord [afield bfield cfield]
>  TestProtocol
>    (printa [_] (println afield))
>    (printb [_] (println bfield))
>    (printc [_] (println cfield)))
> 
> (deftype TestType [afield bfield cfield]
>  TestProtocol
>    (printa [_] (println afield))
>    (printb [_] (println bfield))
>    (printc [_] (println cfield)))
> 
> I haven't found, on Assembla, to submit a ticket, otherwise I would
> have done so. :-)
> 
> Cheers,
> Travis
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> [email protected]
> 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 post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to