Fork me on GitHub
#clj-kondo
<
2021-08-14
>
AJ Jaro15:08:46

I’m just starting to get into clj-kondo and really like it so far! Is it possible that clj-kondo can resolve function names that a macro produces? For example, I have a macro create-utils that generates a set of standard functions like save! and for-id. I tried using the macroexpand utility and I couldn’t get that to work, but I’m not sure if this behavior is possible to resolve with clj-kondo. Could I reference save! or for-id from another namespace and have it resolve successfully? Example:

(ns db.core
 (:require [db.util :as util])

(util/create-utils)
(ns db.test
 (:require [db.core :as core])

(defn get-data []
  (core/for-id 1))

borkdude15:08:39

@ajarosinski example seems incomplete?

👍 3
AJ Jaro15:08:00

I accidentally hit the wrong enter button!! In the example above, I am having trouble resolving for-id in db.test

borkdude15:08:27

what you can do here is use the macroexpand feature to expand into (do (def for-id ..) )

borkdude15:08:50

or just (declare for-id ...)

AJ Jaro15:08:35

Hmm, ok. I will give it another go! Thanks @borkdude

borkdude15:08:49

Let me know when you get stuck, I'm 100% sure this can work :)

borkdude15:08:04

In doubt, stick a println in your macro to see if it gets executed

borkdude15:08:23

and execute clj-kondo from the command line

AJ Jaro15:08:24

That’s the confirmation I needed before I spent a ton of time on it. I really appreciate your support in this channel; it’s downright impressive

7
AJ Jaro20:08:27

Welp, it of course turns out to be user error. It helps a lot of I upgrade to the proper version! :face_palm:

borkdude20:08:09

ah yes, it's a new feature :)

borkdude20:08:28

Perhaps we should add that to the docs

AJ Jaro20:08:52

Meh, I don't know. I definitely knew it was a new feature. Just silliness