[CLJS-2736] Elements returned from sets as functions are not the actual elements in the set. Created: 13/Apr/18  Updated: 15/Jun/18  Resolved: 15/Jun/18

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: 1.10.238
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Paula Gearon Assignee: David Nolen
Resolution: Completed Votes: 1
Labels: bug


 Description   

When a set called as a function returns an element, then the argument is returned rather than the element of the set. This is apparent when the values have metadata:

=> (def my-set #{(with-meta [:a] {:n 42})})
=> (meta (my-set [:a]))
nil
=> (meta (my-set (with-meta [:a] {:x 1})))
{:x 1}


 Comments   
Comment by Paula Gearon [ 13/Apr/18 2:05 PM ]

As per Enzzo Cavallo, this is in the code for -lookup on PersistentHashSet.
(existing code)

(-lookup [coll v not-found]
    (if (-contains-key? hash-map v)
      v
      not-found))

My suggestion is to use similar code to -lookup on PersistentTreeSet (which does not have this bug).

(suggested code)

(-lookup [coll v not-found]
    (if-let [entry (-find hash-map v)
      (key entry)
      not-found))
Comment by David Nolen [ 15/Jun/18 2:39 PM ]

fixed https://github.com/clojure/clojurescript/commit/6b7e9402dd841eeb63e2bb3ae3b397eced388def

Generated at Tue Mar 19 03:02:23 CDT 2019 using JIRA 4.4#649-r158309.