A systematic check of Clojure 1.12.7’s Java-based core used Lean 4 to verify small arithmetic routines and differential testing to compare collections with Java’s standard equivalents. Lean modeled Java integer operations as fixed-width bit vectors, letting it find counterexamples that could then be reproduced in Clojure; larger data structures were tested with randomized sequences of operations. The investigation found 17 bugs with no matching reports in Clojure’s issue tracker or support forum. The results also distinguish bugs from areas that held up: persistent hash maps and sets matched Java maps across three million operations, and tested vector and tree-map behavior showed no discrepancies.
The most serious findings include a `vector-of` reduction that loops forever at 65,505 elements because an incorrect bit mask resets the next chunk’s index to zero, and a persistent hash-map deletion bug that can leave a collision node with a stale hash, making a surviving key visible when printed but inaccessible by lookup. Java interop also behaves differently for `removeIf` depending on whether the compiler knows the receiver’s type. Other examples include integer overflow causing `drop` on a string sequence to throw, and `assoc` with a negative index on a subvector overwriting an element outside that view. The remaining bugs concern numeric conversions, metadata, array and sequence methods, and related edge cases; twelve have comparatively smaller effects.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.