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

+1 vote
in Docs by

From https://github.com/clj-kondo/clj-kondo/issues/1258 :
Some of the functions on transients, specifically assoc! appears to be working even when not handling the return type:

user> (let [t (transient {})]
        (assoc! t :foo :bar)
        (persistent! t))
;; => {:foo :bar}

This blows up when we reach more than 8 entries in the map:

user> (let [t (transient {})]
        (doseq [i (range 10)]
          (assoc! t (str i) i))
        (persistent! t))
;; => {"0" 0, "1" 1, "2" 2, "3" 3, "4" 4, "5" 5, "6" 6, "7" 7}

This seems to hit both beginner and experienced clojure programmers from time to time,
so it might be worth adding a notice to the doc string.

Even though conj! (and perhaps the other fns on transients) seem to work without handling the return type, that might just be an implementation detail, so a warning might be in place there as well

1 Answer

0 votes
selected by
Best answer

This is logged already as https://clojure.atlassian.net/browse/CLJ-1385 (I think it was waiting on me for a better message iirc).