Is there a way to check whether a symbol is bound to at the location :analyze-call is triggered?
Correction: would foo be flagged with Unresolved symbol or Unresolved var
I'm starting to think this info isn't available in analyze-call
api/resolve only checks for vars (or classes) at the moment (I just checked this)
so it won't resolve locals
it could be fixed though
to me it looks like api/resolve will always return some namespace even if the input is garbage
(prn (api/resolve {:name 'foo :call false}))
(prn (api/resolve {:name 'foo :call true}))
will print
{:ns clojure.test, :name foo}
{:ns clojure.test, :name foo}
hmm, probably a bug too :) please file an issue :) this function is too optimistic ;)
it does resolve vars to the correct namespace when they are in the ns form (by alias or refer)
yep, if I give it a valid var name, it does the correct thing
I'll create an issue
what does the :call flag control btw?
I think it has to do with calls to special forms or macros, you can find this in the implementation of resolve-name
checking, thanks
For example in (mymacro foo) , if mymacro is set to be analyzed by a custom hook, can I check in the hook whether foo can be resolved?
you can use hooks-api/resolve https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md
Thank you!
hmm. (api/resolve {:name foo}) always seems to return name and ns whether or not foo is bound in that scope or not. I must be doing something wrong
with resolve do you mean resolve to a var or check whether it's a local?
yeah whether foo means anything in that scope
I mean
either
I'll be back tomorrow
yeah me too 😄
I didn't expect to find you here this time 😅 thanks for the help
I suppose what I'm looking for is: Given (mymacro foo) , I'm looking for a way to decide whether if the hook analyzing mymacro would replace the call with (prn foo), would foo be flagged with Unresolved symbol or not.