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

0 votes
in Compiler by

Set and map literals containing the same constant quoted and unquoted, will throw a duplicate key exception in some cases (the correct behaviour), while silently ignore the duplicate in some others.

`user=> #{'1 1}

{1}

user=> #{'[] []}
IllegalArgumentException Duplicate key: [] clojure.lang.PersistentHashSet.createWithCheck (PersistentHashSet.java:56)
`

This happens because the compiler assumes that literals that have distinct elements at read-time, will have distinct elements at runtime. This is not true for self-evaluating elements where (quote x) is equal to x

2 Answers

0 votes
by

Comment made by: wagjo

Attached patch with tests.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1898 (reported by bronsa)
...