Uploaded image for project: 'Clojure'
  1. CLJ-5

Sequential destructuring of map gives confusing error message

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects versions: None
    • Fix versions: None
    • Approval:
      Triaged
    • Patch:
      Code and Test

      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

            People

            • Assignee:
              Unassigned
              Reporter:
              alex+import import
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: