<< Back to previous view

[CLJ-743] Error messages for invalid destructured bindings are not helpful Created: 22/Feb/11  Updated: 01/Mar/13  Resolved: 24/Feb/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Luke VanderHart Assignee: Luke VanderHart
Resolution: Declined Votes: 0
Labels: None


Errors in destructured forms throw errors that give no clue to what the actual problem is. For example, evaluating (let [[a b] 3] a) throws a 'nth not supported on type Long' error. It is not obvious that the destructuring expression is at fault.

There should be another exception at the top level in the stack trace, something along the lines of of "DestructuringException: value <value> could not be destructured", with the 'nth not supported' exception as its cause.

Comment by Luke VanderHart [ 23/Feb/11 8:27 PM ]

This may not be possible. Destructuring is implemented as a macro-like transformation on the expressions - by the time the expressions are evaluated and an error occurs, the runtime has no way of knowing that the expression was once destructured.

Tagging the expressions with some sort of flag to indicate they were destructured is unviable. Not only is is complicated, it has runtime performance penalties.

Comment by Stuart Halloway [ 24/Feb/11 6:35 PM ]

I don't see a way to do this without runtime implications, even in the no-error case. I guess the destructure macro could emit special variants destructuring-nth and destructuring-get, etc. that provide specaliazed error messages...

Generated at Tue Jan 23 20:11:20 CST 2018 using JIRA 4.4#649-r158309.