The error message generated when case encounters a non-matching clause uses str, resulting in nil being rendered as an empty string, and strings without quote marks.
For example:
And the potentially confusing
Proposed: Use pr-str for the value resulting in nil and "1" respectively
Per the comment thread we moved to doing the exception construction in a separate function, which must be newly accessible from the macro. We applied this patch in Clojure 1.10.2 but pulled it out in 1.10.3 because the reliance of macro expansion on a new function means that compilation of case with 1.10.2 would create bytecode that would not run on older versions of the runtime (that did not have that function).
This patch reverts back to the original inline implementation.
Not going to work on this atm, pulling out of 1.11 bucket
Alex Miller February 16, 2021 at 3:47 PM
Reverted and reopened in 1.10.3-rc1.
By introducing the additional var, this patch caused a compatibility issue. Compiled Clojure code with the change emits a call to a var that does not exist prior to Clojure 1.10.2 so that would fail if used with an older runtime, something like:
Alex Miller September 25, 2020 at 7:21 PM
Released in 1.10.2-alpha2
Alex Miller September 11, 2020 at 8:37 PM
Added alternate clj-2564-2.patch re Rich's comment for consideration.
Rich Hickey August 10, 2020 at 1:34 PM
Can we please look into lifting this error case (throw and printing) into a fn call? That will remove exception handling from case block.
From https://ask.clojure.org/index.php/9152/improve-error-messages-for-clojure-core-case
The error message generated when case encounters a non-matching clause uses str, resulting in nil being rendered as an empty string, and strings without quote marks.
For example:
And the potentially confusing
Proposed: Use pr-str for the value resulting in nil and "1" respectively
Note: a similar issue was raised for Clojurescript here:
https://ask.clojure.org/index.php/6575/improve-error-messages-using-instead-when-printing-objects
Per the comment thread we moved to doing the exception construction in a separate function, which must be newly accessible from the macro. We applied this patch in Clojure 1.10.2 but pulled it out in 1.10.3 because the reliance of macro expansion on a new function means that compilation of case with 1.10.2 would create bytecode that would not run on older versions of the runtime (that did not have that function).
This patch reverts back to the original inline implementation.
Patch: 0001-CLJ-2564-Improve-error-message-for-case.patch
After results for the cases above:
Screened by: Alex Miller