Fork me on GitHub
#clj-kondo
<
2023-01-21
>
Sam Ritchie18:01:06

This form triggers “redundant-fn-wrapper” on clj-kondo v2022.12.08, and I can’t see why… anyone have a clue?

(let [nsm {}]
     (fn [sym]
       `(.println
         (RT/errPrintWriter)
         ~(nsm sym))))

borkdude19:01:59

could be a bug

Noah Bogart20:01:40

I wrote that one. Which part of the form is marked as a violation?

borkdude20:01:05

I think the issue may be that only the code in the unquote is analyzed and the redundant-fn-wrapper isn't aware of the syntax-quote in between

borkdude20:01:29

so then you're left with:

(let [nsm {}]
  (fn [sym]
    (nsm sym)))

borkdude20:01:37

which makes sense, but not with a syntax-quote in the middle

Noah Bogart20:01:30

Oops, you’re right, I merely extended it to keywords.

borkdude20:01:13

@UEENNMX0T If you want to provide a PR to fix the issue, more than welcome ;)

👍 2
borkdude20:01:23

and an issue to track this .. issue

Noah Bogart20:01:27

I’m not at a computer to write the issue but i can take a crack at the fix on Monday

borkdude20:01:00

@U017QJZ9M7W Could you post an issue about this?

Sam Ritchie20:01:43

yes, will do!

Sam Ritchie20:01:24

one more Q for you… I found the following in test.chuck:

(defn ^:private scalb
  [x exp]
  #?(:clj  (Math/scalb ^double x ^int exp)
     :cljs (* x (.pow js/Math 2 exp))))
but the linter reports
src/com/gfredericks/test/chuck/generators.cljc:228:25: error: Unresolved symbol: double
because of this at the top:
(:refer-clojure :exclude [double])
is that correct? should the hint be
(defn ^:private scalb
  [x exp]
  #?(:clj  (Math/scalb ^clojure.core/double x ^int exp)
     :cljs (* x (.pow js/Math 2 exp))))
I had thought that those primitive type hints did NOT have to do with the function names in clojure.core.

borkdude20:01:21

yeah, but I think the type hint might have always worked because clj-kondo analyzed it as a reference to the var ;) so it's a bug, feel free to report

borkdude20:01:44

similar for int I think