Details
-
Type:
Enhancement
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: Backlog
-
Component/s: None
-
Labels:None
-
Patch:Code and Test
-
Approval:Incomplete
Description
The following broken code:
(let [[x y] {}] x)
provides the following stack trace:
Exception in thread "main" java.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap (test.clj:0)
at clojure.lang.Compiler.eval(Compiler.java:4543)
at clojure.lang.Compiler.load(Compiler.java:4857)
at clojure.lang.Compiler.loadFile(Compiler.java:4824)
at clojure.main$load_script__5833.invoke(main.clj:206)
at clojure.main$script_opt__5864.invoke(main.clj:258)
at clojure.main$main__5888.doInvoke(main.clj:333)
at clojure.lang.RestFn.invoke(RestFn.java:413)
at clojure.lang.Var.invoke(Var.java:346)
at clojure.lang.AFn.applyToHelper(AFn.java:173)
at clojure.lang.Var.applyTo(Var.java:463)
at clojure.main.main(main.java:39)
Caused by: java.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap
at clojure.lang.RT.nth(RT.java:800)
at clojure.core$nth__3578.invoke(core.clj:873)
at user$eval__1.invoke(test.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:4532)
... 10 more
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.
Attachments
Activity
| Field | Original Value | New Value |
|---|---|---|
| Attachment | CLJ-5.patch [ 10697 ] |
| Attachment | better-error-for-let-vector-map-binding.patch [ 10725 ] |
| Patch | Code and Test [ 10002 ] | |
| Approval | Incomplete [ 10006 ] | |
| Priority | Minor [ 4 ] | |
| Reporter | Assembla Importer [ importer ] |
| Attachment | clj-5-part2.patch [ 10748 ] | |
| Attachment | clj-5-part1.patch [ 10747 ] |
| Attachment | clj-5-part2.patch [ 10748 ] |
| Attachment | clj-5-part1.patch [ 10747 ] |
| Attachment | better-error-for-let-vector-map-binding.patch [ 10725 ] |
| Comment |
[ Based on feedback, expanded checker to look for nth errors.
Uses patches: clj-5-part1.patch and clj5-part2.patch Will produce {code} user=> (let [[x y] {}] x) Exception let cannot destructure class clojure.lang.PersistentArrayMap. Try converting it to a seq. clojure.core/check-nth-errors (core.clj:3909) user=> (let [[x y] #{}] x) Exception let cannot destructure class clojure.lang.PersistentHashSet. Try converting it to a seq. clojure.core/check-nth-errors (core.clj:3909) user=> (let [[x y] 1] x) Exception let cannot destructure class java.lang.Long. clojure.core/check-nth-errors (core.clj:3910) {code} ] |
| Attachment | clj-5-destructure-error.diff [ 11124 ] |
Converted from http://www.assembla.com/spaces/clojure/tickets/5