clj-kondo

2026-04-06T20:21:21.250979Z

per a discussion in https://clojure.atlassian.net/browse/CLJ-2953, i wonder if clj-kondo should warn on 0-arity uses of eduction:

$ echo "(eduction)" | clj-kondo --lint -
linting took 8ms, errors: 0, warnings: 0

✅ 1
borkdude 2026-04-06T20:35:10.548049Z

what bad things can happen? what does Alex say?

2026-04-06T20:35:36.186189Z

the arglist and docstring contract is 0+ xforms, 1 coll

2026-04-06T20:36:00.946139Z

the impl works if you provide no collection, but it's "undefined behavior"

2026-04-06T20:37:52.487259Z

in the future, the contract might be made explicit and throw if called without a collection

borkdude 2026-04-06T20:38:09.340099Z

how common is this error now?

2026-04-06T20:38:55.006949Z

usage of (eduction) seems to be very limited (2-5 instance on github)

2026-04-06T20:40:02.801589Z

my proposal would be an entry in the args.clj file that has like eduction {:1 {:1 seq :ret any} {:varargs ...}}

2026-04-06T20:40:21.325129Z

(i don't remember the specific format, my apologies)

borkdude 2026-04-06T20:40:42.486709Z

this still doesn't report anything I think, since clj-kondo will also see the varargs signature in the source code

2026-04-06T20:40:59.488019Z

ah, bummer

borkdude 2026-04-06T20:41:02.387299Z

the thing you're mentioning is just for the type system

👍 1
borkdude 2026-04-06T20:41:14.490149Z

but if the source code changes, then clj-kondo will start reporting too

2026-04-06T20:41:34.475779Z

okay

borkdude 2026-04-06T20:45:41.832349Z

Perhaps those weird (eduction) cases on github are because people just needed something of type Eduction

2026-04-06T20:46:13.232939Z

that's very possible

2026-04-06T20:46:48.951629Z

(cc @alexmiller we're discussing that eduction ticket)

borkdude 2026-04-06T20:46:56.225889Z

so a backward compatible way of handling this would be (eduction '()) as the result of (eduction) perhaps

2026-04-06T20:47:26.149539Z

right, alex actually opened an issue about this in one of the cases: https://github.com/uncomplicate/fluokitten/issues/29

Alex Miller (Clojure team) 2026-04-06T20:47:38.388779Z

re the existing uses - yes, I think that's all it is

Alex Miller (Clojure team) 2026-04-06T20:47:59.064949Z

I opened ones for fluokitten and malli. the other ones from Ambrose all seem like tests

👍 2
2026-04-06T20:52:32.091069Z

cool, then never mind. seems folks are using it correctly and we can probably ignore unintended zero-arg arity

Alex Miller (Clojure team) 2026-04-06T20:53:05.225759Z

fluokitten's issue already closed and fixed :)

2026-04-06T21:00:41.678989Z

i've updated the jira ticket with a patch removing the 0-arg arity, so this will be a non-issue when rich reviews and merges my code later this evening 😉

🚀 1
Alex Miller (Clojure team) 2026-04-06T21:04:18.116969Z

ha