I checked Clojure's core with Lean and found unreported bugs(s.conao3.com)
237 points by encyclopedism 4 days ago | 81 comments
tl;dr: Using Lean 4 to model small Clojure core functions and differential testing against java.util collections, the author found 17 previously unreported bugs in Clojure 1.12.7. Notable issues include an infinite loop in `reduce` on `vector-of` with ≥65505 elements (caused by a bad 0xffe0 bitmask), a HAMT `dissoc` bug that stores the wrong hash on collision nodes and can hide keys, and `.removeIf` returning different results depending on whether a type hint triggers reflection. The large persistent data structures themselves (HAMT, vector trees, red-black trees) showed no mismatches.
HN Discussion:
  • ↓Some reported bugs are actually correct behavior due to type coercion, reducing the finding's significance
  • ↑Similar formal verification efforts have found bugs in other Lisp implementations too
  • ↑Surprise that core Clojure has such bugs given its use in production by major companies
  • •Curiosity about Lean's growing use for verification versus Rocq/Coq
  • ~Verification is theoretically exciting but limited by the unverifiable JVM underneath