Details
-
Type:
Defect
-
Status:
Closed
-
Priority:
Major
-
Resolution: Completed
-
Affects Version/s: Release 1.2
-
Fix Version/s: Release 1.4
-
Component/s: None
-
Labels:None
-
Patch:Code and Test
-
Approval:Ok
Description
If you botch or misunderstand certain macros in core, they throw exceptions with very unhelpful error messages:
=> (let [a]) #<IllegalArgumentException java.lang.IllegalArgumentException: let requires an even number of forms in binding vector> => (if-let [a 5 b 6] true) #<IllegalArgumentException java.lang.IllegalArgumentException: if-let requires exactly 2 forms in binding vector>
No mention of userland file/namespace or line number is in the stack trace. If this code happens to be in code being loaded via some chain of :requires, tracking it down can be way more painful than it reasonably should be.
Something like this would be much better:
#<IllegalArgumentException java.lang.IllegalArgumentException: let requires an even number of forms in binding vector in com.foo.namespace:80>
These errors are all thrown via the same assert-args function used by a variety of macros in clojure.core; modifying it so it emits a reasonable error message should be straightforward.
Only affects the assert-args macro, which is private in clojure.core. Patch works as advertised.