Sequential destructuring of map gives confusing error message

Description

The following broken code:

provides the following error:

Stack trace:

The message "nth not supported on this type" while correct doesn't make the cause of the error very clear. Better error messages when destructuring would be very helpful.

Environment

None

Attachments

2

Activity

Show:

Kevin Downey April 18, 2014 at 7:45 AM

I am not wild about that error message, let can destructure a map fine.

If there error message were to change, I would prefer to get something like "sequential destructing not supported on maps".

I actually like the "nth not supported" error message, because it is exactly the problem, nth, used by sequential destructuring, doesn't work on maps.

it conveys exactly what the problem is if you know how destructing works and what nth means, where as "UnsupportedOperationException let cannot destructure class clojure.lang.PersistentArrayMap" seems misleading when you are in the know

Carin Meier April 29, 2012 at 4:46 AM

File: clj-5-destructure-error.diff

Added support for nested destructuring errors

Carin Meier December 16, 2011 at 1:47 PM

Unfortunately, realized that this still does not cover the nested destructuring cases. Coming to the conclusion, that my approach above is not going to work for this.

Aaron Bedra December 1, 2011 at 1:12 AM

This seems too specific. Is this issue indicative of a larger problem that should be addressed? Even if this is the only case where bindings produce poor error messages, all the cases described above should be addressed in the patch.

Carin Meier November 30, 2011 at 6:15 PM

Add patch better-error-for-let-vector-map-binding

This produces the following:

There are other cases that are not handled by this though — like binding vector to a set

Wondering if it might be better to try convert the map to a seq to support? Although this might be another issue.

Thoughts?

Details

Assignee

Reporter

Approval

Triaged

Patch

Code and Test

Priority

Created June 17, 2009 at 8:35 AM
Updated January 19, 2022 at 8:10 PM