clj-kondo

a13 2025-07-25T14:56:02.348519Z

Hello again. I'm getting an unexpected error: "Expected: char sequence or nil, received: map." The minimal example:

(defn foo []
  (let [res (str)] ; any fn with ":ret :string", identity
    {:b {:a res}})) ; works fine with (subs "" 0)

(str/split-lines
 (:a ;<- here is the problematic line 
  (:b
   (foo))))
Everything works fine if I use a nesting level other than 2. If I bind foo locally - it works fine too.

borkdude 2025-07-25T15:08:06.144509Z

bug, can you report it?

borkdude 2025-07-25T15:08:11.789729Z

on github issues

a13 2025-07-25T15:08:21.867779Z

sure

a13 2025-07-25T15:12:05.548719Z

https://github.com/clj-kondo/clj-kondo/issues/2575 sorry, pretty short one, I'm a bit busy rn

borkdude 2025-07-25T15:12:25.598579Z

thanks!

borkdude 2025-07-25T15:12:41.319289Z

I'm also busy, with other clj-kondo issues laughcry

🫂 1
borkdude 2025-07-25T15:34:58.917609Z

PSA ⚠️ Please try clj-kondo :mvn/version "2025.06.06-20250725.153320-16" if you can. This should solve a memory issue. The goal is to be as fast as before, not slower. So if you can run this version against your main projects, that's be sweet.

markaddleman 2025-07-25T17:24:05.482309Z

Claude likes to generate code with nested reader conditionals (ie, #?(:cljs #?(:cljs (blah))). I don’t think clj-kondo has a linter to detect this situation and I can’t find documentation on how reader conditionals are represented in the AST. Can someone point me in the right direction?

😂 1
wcohen 2025-07-26T23:21:55.392149Z

Can confirm Claude went nuts doing this in a cljc for me this past month

borkdude 2025-07-25T17:32:19.265569Z

This isn't invalid per se. E.g. sometimes I write:

#?(:clj (do #?(:clj 2 :bb 3))

markaddleman 2025-07-25T17:32:45.442909Z

fair enough but claude seems to like

#?(:cljs (do #?(:clj 2 :bb 3))

borkdude 2025-07-25T17:32:54.889599Z

that's surely invalid

borkdude 2025-07-25T17:33:01.377839Z

I mean, not invalid, but nonsense

markaddleman 2025-07-25T17:33:08.840389Z

🙂

markaddleman 2025-07-25T17:33:10.694639Z

exactly

markaddleman 2025-07-25T17:33:34.282739Z

clj-kondo does a decent job of keeping claude on a good path

borkdude 2025-07-25T17:33:55.028119Z

we could make this a linting thing yeah, issue welcome

markaddleman 2025-07-25T17:34:25.309199Z

I have a few project-specific linters that help maintain architectural sanity. This particular linter would help a lot, I think

markaddleman 2025-07-25T17:34:31.250059Z

Yeah, I’ll open an issue

borkdude 2025-07-25T17:36:28.797869Z

how it works in clj-kondo: it (currently) lints .cljc files two times: once for clojure and once for clojurescript. it selects the reader conditionals in a function called select-lang recursively. so we'd have to check this in this logic

borkdude 2025-07-25T17:36:38.509009Z

after that clj-kondo is unaware of any reader conditionals

markaddleman 2025-07-25T17:37:21.547509Z

ah, so it doesn’t currently have the opportunity to detect a nested situation

borkdude 2025-07-25T17:37:47.251359Z

yes, in select-lang I think

markaddleman 2025-07-25T17:37:54.211149Z

oh ok

borkdude 2025-07-25T17:37:55.626299Z

but not sure

markaddleman 2025-07-25T17:38:18.705139Z

gotcha. I’ll open an issue and take a look at the code