clj-kondo

Cam Saul 2025-08-11T21:15:23.365629Z

Hey wanted to post here to make sure I'm not insane before opening a bug. I tried updating Kondo from 2025.04.07 to 2025.07.28 today and ran into what I'm almost certain are some false positives with the :condition-always-true linter

(ns metabase.kondo-repro)

(defn x [y]
  (when-let [k (keyword y)] ; <- warning is on this line
    k))

(x "A")
;; => :A

(x nil)
;; => nil
Then when I run Kondo on this file:
src/metabase/kondo_repro.clj:4:16: warning: Condition always true
It seems like the linter assumes (keyword ...) always returns something truthy but (keyword nil) => nil, right?

✅ 1
borkdude 2025-08-11T21:16:46.341869Z

In theory you are correct, but I think relying on the keyword function returning nil is against its docstring, therefore keyword is typed as returning always a keyword in clj-kondo's type system

Cam Saul 2025-08-11T21:17:08.634049Z

oh ok that makes sense. Thanks!