Thanks a lot for this /u/alexdmiller . Can the value be printed along with the exception in some cases like below
Current error on 1.10
(map identity (map 123 (range 10)))
Error printing return value (ClassCastException) at clojure.core/map$fn (core.clj:2753).
java.lang.Long cannot be cast to clojure.lang.IFn
Adding the value that cannot be cast might give better context
(map identity (map 123 (range 10)))
Error printing return value (ClassCastException) at clojure.core/map$fn (core.clj:2753).
java.lang.Long (123) cannot be cast to clojure.lang.IFn
The error message phase here is in printing the return value. So it can’t be printed, because that is where the error occurs. A lot of lazy sequence errors end up looking like this.
This particular error is a case where the invocation is wrong (args swapped), which is really a perfect case for a spec or precondition, to avoid constructing a broken lazy seq. I’ve been thinking we should probably improve the particular “can’t cast to IFn” too since it’s so common.
Thanks for the reply. I guess there had been attempts to spec clojure's core functions but they were abandoned due to various reasons. I would love to see upcoming improvements.
2
u/xtreak Dec 19 '18
Thanks a lot for this /u/alexdmiller . Can the value be printed along with the exception in some cases like below
Current error on 1.10
Adding the value that cannot be cast might give better context