clj-kondo

p-himik 2025-07-02T15:29:06.858619Z

Would it make sense to add checks for the following patterns and recommend a user to use case instead?

(cond
  (= x :a) ... ;; Any case-supported constant can be used, not just keywords
  (= x :b) ...
  ...)

(condp = x
  :a ...
  :b ...
  ...)

(condp contains? x
  #{:a} ...
  #{:b :c} ...
  ...)

➕ 2
borkdude 2025-07-02T15:42:43.032179Z

Sure yeah

borkdude 2025-07-02T21:33:39.190549Z

Would you mind posting an issue about this? What are the edge cases, e.g. should all compared things be of the same type (if you're not doing that sometimes case will fall back to condp I believe)

p-himik 2025-07-02T21:42:52.971259Z

Sure, will do. Yeah, I think case does fall back to condp = but only in some cases, and it by itself is an unlikely reason to prefer an explicit condp =.

p-himik 2025-07-02T21:46:21.701989Z

Ah, except for the performance warning when warn-on-reflection is set and there are hash collisions in the constants.

p-himik 2025-07-03T02:06:59.311359Z

https://github.com/clj-kondo/clj-kondo/issues/2563 > should all compared things be of the same type I don't think the type itself matters. Unless all constants are integer numbers that fit into 32 bits, case will uses hashes. And as shown in the issue, collisions can happen regardless of the types or of whether they're homogeneous.