Improve error messages for `case`

Description

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

Patch: clj-2564-3.patch

Patch updated per Rich's comments. After results for the cases above:

Environment

None

Activity

Show:
Alex Miller
July 31, 2020, 3:56 AM

Given that we are matching compile-time constant values here, I do this pr-str would be clearer in these error messages.

Rich Hickey
August 10, 2020, 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.

Alex Miller
September 11, 2020, 8:37 PM

Added alternate clj-2564-2.patch re Rich's comment for consideration.

Alex Miller
September 25, 2020, 7:21 PM

Released in 1.10.2-alpha2

Fixed

Assignee

Unassigned

Reporter

Alex Miller

Labels

Approval

Ok

Patch

Code

Fix versions

Priority

Minor
Configure