Skip to content

Commit f1981a4

Browse files
thomasmulvaneydnolen
authored andcommitted
CLJS-1780: Records without extmaps fail to iterate
1 parent 5f4ee99 commit f1981a4

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/main/clojure/cljs/core.cljc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,10 @@
17781778
~'__extmap)))
17791779

17801780
'IIterable
1781-
`(~'-iterator [~gs] (RecordIter. 0 ~gs ~(count base-fields) [~@(map keyword base-fields)] (-iterator ~'__extmap) ))
1781+
`(~'-iterator [~gs]
1782+
(RecordIter. 0 ~gs ~(count base-fields) [~@(map keyword base-fields)] (if ~'__extmap
1783+
(-iterator ~'__extmap)
1784+
(core/nil-iter))))
17821785

17831786
'IPrintWithWriter
17841787
`(~'-pr-writer [this# writer# opts#]

src/test/cljs/cljs/core_test.cljs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3245,6 +3245,17 @@
32453245
(is (= (hash (keyword 'app "foo"))
32463246
(hash (keyword "app" "foo")))))
32473247

3248+
(defrecord CLJS1780 [a b c])
3249+
3250+
(deftest test-cljs-1780
3251+
(let [record (->CLJS1780 1 2 3)]
3252+
(is (= (into #{} (sequence (map identity)
3253+
record))
3254+
#{[:a 1] [:b 2] [:c 3]}))
3255+
(is (= (into #{} (sequence (map identity)
3256+
(assoc record :d 4 :e 5)) )
3257+
#{[:a 1] [:b 2] [:c 3] [:d 4] [:e 5]}))))
3258+
32483259
(comment
32493260
;; ObjMap
32503261
;; (let [ks (map (partial str "foo") (range 500))

0 commit comments

Comments
 (0)