The investigation applies Lean 4 formal verification and differential testing to Java code in Clojure 1.12.7, looking for defects in core functions and persistent collections. Lean modeled integer and bit operations and searched for counterexamples; larger data structures were compared with Java collections under randomized operation sequences. The checks uncovered 17 previously unreported bugs, including errors in primitive-array vectors, hash maps, Java functional-interface calls, numeric conversions, and sequence operations. The most severe examples include `reduce` on a `vector-of` looping forever at 65,505 elements because a bit mask resets the chunk position, and a HAMT hash-collision bug that leaves a map entry visible when printed but unreachable by lookup.
Other findings expose inconsistent or unsafe edge cases: `.removeIf` behaves differently depending on whether the Java collection’s type is known, integer overflow can make dropping from a string sequence throw, and a negative `subvec` index can modify the underlying vector outside the view. Twelve additional defects include unexpected conversion results, incorrect metadata retention, and disagreements between sequence search methods. The testing also found important areas with no mismatch: three million HAMT operations agreed with `HashMap`, vector operations matched `ArrayList` around tested tree boundaries, and tested tree-map invariants held. The results suggest that bugs persist outside well-established data-structure cores, especially where separate mechanisms - such as hashing and equality or compiler and reflective interop - meet.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.