Fork me on GitHub
#clj-kondo
<
2023-12-05
>
Colin (fosskers)08:12:37

I have a question about Malli integration. I have some simple examples working, but stumbled upon this:

(def Pkg [:map {:closed true}
          [:Description :string]])

(defn fooz
  "zii"
  {:malli/schema [:=> [:cat Pkg] :string]}
  [pkg]
  (:Name pkg))

(comment
  (fooz {:Name "hi"}))
I will see red squigglies in the buffer regarding a lack of :Description at the call site, but I'm not warned about the illegal call to :Name within fooz. Malli itself warns about it in the repl at execution time, but that doesn't seem to propagate to the buffer squigglies.

elken08:12:38

For extra context, the configuration have been generated using https://tonitalksdev.com/take-your-linting-game-to-the-next-level?showSharer=true Might also be worth posting the config.edn it spat out @U058DHAN3UP

Colin (fosskers)13:12:10

{:linters {:unresolved-symbol {:exclude [(malli.core/=>)]},
           :type-mismatch {:namespaces {packages {fooz {:arities {1 {:args [{:op :keys, :req {:Description :string}}],
                                                                     :ret :string}}}}}}}}

elken13:12:15

Ah, seems like the fact it's a closed map isn't being reported so the fault may be #CLDK6MFMK after all

Colin (fosskers)13:12:57

Cool, it's also smart enough to look inside of things

Colin (fosskers)13:12:12

But it's only reporting the issue where it's actually a problem, namely the function call

Colin (fosskers)13:12:22

There's nothing wrong with the let-binding itself.

Colin (fosskers)13:12:54

Does Kondo understand closedness for Malli to even tell it about it?

elken13:12:17

Right, there's nothing to report because that symbol doesn't have any awareness until you try and use fooz which flags a :type-mismatch lint

Colin (fosskers)13:12:57

If kondo does understand closedness, then this is a Malli bug. If it doesn't, this is a kondo feature request.

elken13:12:18

Agreed, one for borkdude to answer when he sees this 😄

Colin (fosskers)13:12:34

Will the scent of 🍖 attract him...?

Colin (fosskers)13:12:55

It's 22:30 here though, I don't need an answer tonight 😆

borkdude13:12:19

it's easy to find out using clj-kondo only, if you can make a repro without any downstream dependencies I'll have a look

🙌 1
Colin (fosskers)13:12:23

The issue is that we're not sure how closedness of a Map is supposed to be communicated between the tooling (or if Kondo knows about the concept to begin with).

Colin (fosskers)13:12:39

The repro is the code I posted further up ^^^

borkdude13:12:40

clj-kondo knows about required keys, but not about closedness

Colin (fosskers)01:12:10

Ah ha! Is that a reasonable feature request to make? Shall I open a ticket?

👍 1
Colin (fosskers)08:12:47

What's expected behaviour here? Please and thanks.