A Lean 4 Check of Clojure 1.12.7 Found 17 Bugs the Author Could Not Find in Any Upstream Ticket
Software / news
A Lean 4 Check of Clojure 1.12.7 Found 17 Bugs the Author Could Not Find in Any Upstream Ticket
Naoya Yamashita combined a theorem prover with 3 million differential-test operations; the Clojure tracker already shows how slowly some adjacent bugs move.

Naoya Yamashita, who publishes as conao3, reported on November 24 that checking parts of Clojure 1.12.7 with the Lean 4 prover and differential tests turned up 17 bugs, none of which he found in the language's issue tracker or on ask.clojure.org.
His write-up was inspired by a Zenn article on formally verifying Rust projects with Lean. It is a single-author blog post, and the fixes in it are proposals, not merged changes.
How the 17 bugs were found
Yamashita modeled Java long and int as 64-bit and 32-bit vectors and used Lean's bv_decide to search small functions for counterexamples against a wider specification. He also ran differential tests of Clojure's hash map, set, vector and tree map against java.util collections. The hash array mapped trie (HAMT) test covered 3 million operations across 2,000 random seeds.
The core data structures held up. The HAMT and vector trees showed no mismatches, and the bugs sat in peripheral code and where mechanisms meet, such as type hints on Java interop calls.
The five bugs the post walks through
| Bug | Symptom | Cause |
|---|---|---|
reduce on a vector-of | Never returns at 65,505 or more elements | 0xffe0 mask in gvec.clj |
HashCollisionNode.without | Lookups fail after dissoc, and disj is the same | Stores the removed key's hash, not this.hash |
.removeIf | Different results with and without a type hint | Interop dispatch |
drop on string seqs | Integer overflow | Int arithmetic |
assoc on a subvec | Accepts a negative index and writes outside the subvec | Missing bounds check |
The other 12 appear only in a table: reduce-kv on vector-of, next keeping metadata, long and int of ##NaN, clamping of large doubles, char wrapping a BigInt, get truncating fractional indices, byte-array and short-array rejecting an initial value, and a mismatch between .indexOf and .contains on primitive-array seqs.
What the Clojure tracker already holds
The post points to three related tickets, and Clojure's public JIRA shows how differently they went. CLJ-1372, "Inconsistent hash with java collections", was created on March 9, 2014 and is still open in the Backlog. CLJ-2864, on truthy return logic in functional-interface adapters, was filed on June 14, 2024 and fixed in Release 1.12.
CLJ-962 is the telling one. Its title is "Vectors returned by subvec allow access at negative indices," and it was closed as completed in Release 1.5. Yamashita says assoc on a subvec still shares the flaw, so a bug filed in March 2012 and marked fixed has a sibling that was never closed.
Limits of the proof
Lean checks models, not the Java source, so the claim that each model matches the code rests on the author's own comparison. The solver timed out on 16-bit multiplication, so only 8-bit and 10-bit cases were checked for the subvec, drop and reduce fixes. Lean did prove up to 32 bits that clojure.core/mod matches a floored remainder.
For the HAMT fix he patched and compiled PersistentHashMap.java locally, after which his example returned :B. Differential testing shows only that tested inputs agree. His searches of JIRA, which used its REST API, and of the forum may also be incomplete.
The post mentions no response from the Clojure core team. Whether any of the 17 becomes a JIRA ticket is the next thing to watch. Clojure runs on the JVM, where Java4Shell was a Base64 bug in OpenJDK 17.0.6 and later, and the argument about report volume is live elsewhere: Gentoo's packager and curl's 87-bug bounty data.
Sources
More in Software
- 01One Developer Reached 118 FPS in iOS Safari by Reading Scroll Position, and WebKit Still Defaults to 60Rida F'kih's technique avoids touch events entirely; WebKit's own bug tracker shows the 60 FPS cap is a default flag, not a hardware limit.
- 02Hex.pm Says an Attacker Ran Commands on Six Web Servers on Nov. 23, and Password Hashes May Be ExposedThe Elixir and Erlang package registry traced the breach to a 2016 decoder change, found no tampered packages, and is asking every user to change passwords and reset 2FA.
- 03OpenLaszlo Co-Founder David Temkin Releases Declare, an MIT UI Language for LLMs, With Single-Run NumbersThe page claims 1,279 lines against React's 2,666 for the same ticket app, and labels its own evaluation "not yet a benchmark."
- 04StarSling's Agents Rewrite GitHub Actions Workflows, and Commenters Ask What Gets DeletedThe YC P25 company reports 3.9x to 36.4x speedups on open-source repos. Every figure is its own, and the thread leaves test weakening unanswered.