A developer applied formal verification and differential testing to Clojure 1.12.7, uncovering 17 previously unreported bugs. Using the lean-verify procedure, integer and bit arithmetic were modeled in Lean 4 to find counterexamples. Differential testing compared Clojure's persistent data structures against java.util collections.
The investigation revealed critical flaws, including a reduce function on vector-of that hangs with 65505 or more elements due to a bit masking error in gvec.clj. The HAMT hash collision node and functional interface calls without type hints also showed mismatches. While the HAMT itself passed 3 million differential operations, bugs exist in the intersection of separate code mechanisms.
The author verified fixes by modeling corrected code in Lean. These findings highlight the value of formal methods in detecting subtle edge-case bugs in mature, widely-used open-source projects like Clojure.
Source: Hacker News · Summarized by HeadlinesBriefing