Fork me on GitHub
#clj-kondo
<
2019-12-12
>
Aleed02:12:16

why is the following snippet giving me an unresolved symbol error for the ~@args# declaration?

(defn example
  [name]
  `(defmacro ~name [& args#]
     `(foo ~(keyword '~name) ~@args#)))

borkdude08:12:17

@alidcastano Because the author did not know that syntax-quotes are allowed to be nested

borkdude08:12:11

Feel free to post an issue

teawaterwire14:12:40

how to tell kondo it's ok?

borkdude14:12:14

@teawaterwire what version of clj-kondo are you using and which editor / plugin?

teawaterwire14:12:38

sorry yes more details: vscode with calva it's on clojurescript code i'm tagging a symbol to be treated as js

borkdude14:12:03

is it only a .cljs file or maybe a .cljc file?

borkdude14:12:16

if you can give a repro using a small code snippet, that would be helpful

teawaterwire14:12:54

yes trying to isolate a simple snippet

teawaterwire14:12:09

i tried this mini-snippet

borkdude15:12:13

can you please just paste the code instead of screenshots? then I can repro it myself

borkdude15:12:52

never mind, (.log js/console ^js #js [1 2 3]) is enough to reproduce it

borkdude15:12:48

I'll make an issue for it. meanwhile you can add this symbol to your .clj-kondo/config.edn config

teawaterwire15:12:12

sorry for the screenshot thank you for the answer!

borkdude14:12:33

and please give some more context, repro using text instead of a screenshot

mafcocinco14:12:38

Question regarding HugSQL but I think it speaks to a more general (potential) issue: I'm not sure if anyone has used HugSQL, but it dynamically defines clojure functions based on a markup syntax within the comments of an SQL file. As one might imagine, clj-kondo has no context/understanding that these functions exist (they are generated by loading the SQL file with a function that HugSQL provides). Any thoughts on how to handle HugSQL specifically and, perhaps more importantly, how to handle dynamically generated functions (i.e. functions that are produced via calls to eval, etc.)?

mafcocinco14:12:56

Cool, makes sense as the declare call will introduce the symbol in a context that clj-kondo knows about. Clever solution. Thanks.

borkdude14:12:21

I'm also using hugsql myself and this is how I do it as well

mafcocinco14:12:47

Yeah, I generally have a wrapper clj file that should be included to use the hugsql functions, which avoids redundant declarations of the functions. Would be easy to add the declare statements in those files. Also has the side benefit of surfacing the names of the functions that the SQL file provides without the user having to dig into the SQL file.

borkdude14:12:27

I found that helpful too

avi20:12:17

👋 is this a known issue or am I doing something weird here, or just missing something?

;; clj-kondo is warning about this first line: warning: unused binding alias-sym
  (doseq [[ns-sym _ alias-sym] (cons t ts)]
    (create-ns ns-sym)
    (alias alias-sym ns-sym))
I’m using v2019.11.23 with the default config.

borkdude20:12:43

not wrong, probably a bug in the analysis of alias, sorry 🙂

borkdude20:12:11

usually alias is called with a literal symbol, that's why it didn't show up before

avi20:12:25

Aha! no worries. I’ll open an issue. Thank you!

borkdude20:12:54

btw, I enjoyed your talk on fc4

avi20:12:20

oh, thanks! That’s great to hear! 😊

avi20:12:27

Thanks for clj-kondo!