Fork me on GitHub
#clojure-dev
<
2016-08-12
>
seancorfield00:08:11

Is this a bug or just an "expected weirdness"

boot.user=> (let [{:foo/keys [a b] :bar/keys [a b c] :as all} #:foo{:a 1 :b 2 :c 3 :bar/a 4 :bar/c 5 :d 6 :bar/e 7}] [a b c all])
[4 nil 5 {:foo/a 1, :foo/b 2, :foo/c 3, :bar/a 4, :bar/c 5, :foo/d 6, :bar/e 7}]
boot.user=> 

seancorfield00:08:54

My initial thought was that this should throw an exception as a and b are duplicated in the destructuring...

seancorfield00:08:28

…since it doesn’t, I’ll assume either "undefined behavior" or "last declaration wins" (but likely the the former since maps are inherently unordered).

hiredman01:08:25

and that destructuring is not expressable in the desugared destructuring form, because it is a map

seancorfield01:08:15

So… undefined behavior… that just isn’t detected (and flagged) by the compiler?

hiredman01:08:50

not useful behavior in any case, right?

Alex Miller (Clojure team)02:08:25

yeah, we talked about this when implementing and decided that if you do this, what happens is undefined, so don’t do that

Alex Miller (Clojure team)02:08:56

you’re asking for something that has no meaningful result

seancorfield02:08:15

Yeah, I’m happy with either an exception (if detecting it had zero cost) or undefined behavior. It’s an obvious "shouldn’t work" situation as far as I was concerned.