Share your thoughts in the 2024 State of Clojure Survey!

Welcome! Please see the About page for a little more info on how this works.

+1 vote
in ClojureScript by

(let [{x :x} '({:x "foo"})] x)
;; => "foo"

2 Answers

+1 vote
by

Has nothing to do with tooling - it's just how destructuring works in Clojure:

user=> (clojure.pprint/pprint (destructure '[{a :a} []]))
[map__6
 []
 map__6
 (if
  (clojure.core/seq? map__6)
  (if
   (clojure.core/next map__6)
   (clojure.lang.PersistentArrayMap/createAsIfByAssoc
    (clojure.core/to-array map__6))
   (if
    (clojure.core/seq map__6)
    (clojure.core/first map__6)
    clojure.lang.PersistentArrayMap/EMPTY))
  map__6)
 a
 (clojure.core/get map__6 :a)]
nil

This behavior in particular is a side-effect of implementing this ticket: https://clojure.atlassian.net/browse/CLJ-2603

by
Thanks. So just to clarify: Is this behaviour intended or is it an unintended side-effect (of intended behaviour elsewhere)?
by
I don't know for sure but I would assume the latter, given that ticket.
by
Yes, this is the intended and expected behavior.
0 votes
by

Ok, I just realized that this might be a problem in shadow-cljs or other downstream tooling that I’m using.

by
(I’m using ClojureScript 1.11.57 here btw)
Welcome to Clojure Q&A, where you can ask questions and receive answers from members of the Clojure community.
...