On Tue, Feb 08, 2011 at 09:01:38AM -0500, Stuart Halloway wrote:
> Please let us know when you get a misleading error message from a
> macroexpansion, so we can make it better. Or contribute a patch along the 
> lines
> of [2].

Here's another error message that really threw me off for a while.

I have some code that looks like this:

    (let [[x y] (nth @my-atom z)]
      ...)

Which occasionally failed with:

    java.lang.UnsupportedOperationException: nth not supported on this type: 
Float
    at clojure.lang.RT.nthFrom(RT.java:815) ~[clojure-1.2.0.jar:na]
    at clojure.lang.RT.nth(RT.java:765) ~[clojure-1.2.0.jar:na]

I tried to figure out how a single float could have ended up in that
atom and why I couldn't catch it by checking for `(coll? @my-atom)`.
After a while I found out that `@my-atom` indeed contained a
collection -- a collection of floats -- and that the exception was
thrown by the destructuring.

An error message something like this would have been much more helpful:

    Can't destructure `(nth @my-atom z)` to `[x y]`: expected a
    collection with 2 or more items but got `Float`.

--
Timo

-- 
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

Reply via email to