I checked Clojure's core with Lean and found unreported bugs s.conao3.com · 13 p...
HN Best 200 @best
I checked Clojure's core with Lean and found unreported bugs s.conao3.com · 13 points · 2 comments · HN thread
TL;DR The author used Lean 4 with bit-vector solving and differential testing against java.util collections to audit Clojure 1.12.7's Java-side core, reporting 17 previously unreported bugs. The headline bugs are a non-terminating reduce on vector-of past 65505 elements, a HAMT collision-node dissoc that hides keys, and reflection-dependent results for functional-interface calls like removeIf. The HAMT and vector trees themselves showed no mismatches.
- reduce on vector-of never terminates once the vector has 65505 or more elements, because a 0xffe0 mask in gvec.clj wraps the next chunk start to 0 after index 65504.
- HashCollisionNode.without passes the parameter hash instead of this.hash, so dissoc with a key that is = but has a different hash corrupts the node; disj on hash-sets is affected, transient dissoc! is not.
- Calls to functional interfaces with a type hint and without one (reflection) give different results for removeIf, due to CLJ-2864 changes and Reflector.coerceAdapterReturn.
- Integer overflow in StringSeq.drop and a negative index accepted by SubVector.assocN are also reported, with 12 smaller issues such as (long ##NaN) returning 0.
- The HAMT (3 million operations), the vector tree at boundaries, PersistentTreeMap, and Numbers overflow checks showed no mismatches; the author says all proven properties hold for the models shown.
Discussion The thread is very small, with only two comments. One commenter jokingly suggests that Rich Hickey should return to his hammock, a reference to his 'hammock-driven development' talk. The reply pushes back that hammock-driven development was never meant to produce bug-free code. The mood is light and mostly dismissive of the joke rather than of the findings, and the bug details themselves are not discussed.
- Joking that Clojure's creator should rest rather than fix bugs (some): One commenter jokes that Rich Hickey needs to get back to his hammock, implying the bugs show a lack of care in the core library.
- Hammock-driven development does not target bug-free code (a few): A reply points out that Rich Hickey's hammock-driven development is about thinking through design, not producing bug-free implementations, so the joke misreads it.