Fork me on GitHub
#clj-kondo
<
2021-06-04
>
slipset09:06:54

Could this be linted?

(defprotocol Bar
  (bar [_ x]))

(defrecord foo [x]
  Bar)

(bar (->foo 1) 1) ;; explodes
So basically a warn (or error) on missing implementation of protocol-fn?

borkdude10:06:31

I think it could

Karol Wójcik13:06:20

I think I found a false positive with clj-kondo. something.cljc

(let [lname "hello-world"
      gfullname #?(:bb nil
                   :clj (symbol (str (ns-name *ns*) "." lname)))
      gclass #?(:bb nil
                :clj (println gfullname)
                :cljs nil)])
❯ clj-kondo --lint something.cljc     
something.cljc:1:6: error: let binding vector requires even number of forms
something.cljc:1:7: warning: unused binding lname
something.cljc:2:7: warning: unused binding gfullname
something.cljc:4:7: warning: unused binding gclass
something.cljc:4:7: error: Unresolved symbol: gclass
something.cljc:6:23: error: unsupported binding form nil
linting took 35ms, errors: 3, warnings: 3
Can someone reproduce it as well? clj-kondo v2021.05.31

dominicm20:06:13

Btw, you can use :default to target (not :clojure): #?(:clj (symbol …) :default nil)

borkdude13:06:07

have you tried to run it? ;)

borkdude13:06:24

especially in CLJS it should not work

borkdude13:06:51

cljs.user=> (load-file "/tmp/something.cljc")
Unexpected error (ExceptionInfo) macroexpanding cljs.core$macros/let at (<cljs repl>:1:1).
let requires an even number of forms in binding vector

Karol Wójcik13:06:35

Oh 😂 My bad! I have tried java/bb 😄

borkdude13:06:15

do you want to run this file in CLJS as well btw?

Karol Wójcik13:06:37

In some time probably yes

borkdude14:06:47

@slipset feel free to create an issue