Fork me on GitHub
#clj-kondo
<
2021-04-14
>
Sigve08:04:14

Even though kondo added Core.match support in 2021.02.13 i still get errors on _ and variable binding. Anything i can do about this?

src/language.cljs:52:17: error: Unresolved symbol: _
src/language.cljs:148:66: error: Unresolved symbol: last-type
src/language.cljs:149:74: error: Unresolved symbol: opt
...

borkdude08:04:43

Well, the first step would be to provide a valid repro

Sigve08:04:52

Ok, so kondo should recognise these patterns in theory?

borkdude08:04:13

in depends: I can't see where these errors are coming from by the text you posted

Sigve08:04:21

Of course, sorry: around line 52:

(match [word-class source-type (h/import-type ast) last-valid first-failure expr-settings]
               [_ _ _ (_ :guard (partial h/empty-command? command)) _ _] [:command]

               ...)]
around line 148:
(match [word-class (h/empty-word? word) source-type last-valid first-failure expr-settings option-settings]

          ...
          [:option false _ _ _ _ {:inside-paren? true :last-type last-type}]   #{last-type}
          [:option _ _ _ _ _     {:parenopt? true :closed? false :option opt}] #{(h/opt-param-type command (:name opt))}

          ...)]

Ben Sless13:04:20

Hey, I believe I'm missing it in the documentation, but how do I register macros with lint-as in a namespace's metadata?

Ben Sless13:04:50

I think I figured it out, noting it here for posterity: :clj-kondo/config in the ns form takes a quoted map. for it to work the linted-as symbol needs to be fully qualified. Is there anything I missed?

borkdude13:04:42

this is correct

borkdude14:04:55

@sigve.nordgaard I don't get any lint warnings using this:

(require '[clojure.core.match :refer [match]])

(let [command :foo]
  (match []
         [_ _ _ (_ :guard (partial apply command)) _ _] [:command]
         ))

borkdude14:04:15

But you are in .cljs I see. Never tested that case, it seems the libspec is different there:

[cljs.core.match :refer [match]]
I will fix that, but for now you can use {:lint-as {cljs.core.match/match clojure.core.match/match}}