feat(strictness): transient bang ops require a transient; conj! arities

conj!/assoc!/dissoc!/disj!/pop!/persistent! now throw on a non-transient (or
wrong transient kind) instead of falling back to the persistent op, matching
Clojure. conj! keeps its special arities: (conj!) -> (transient []), (conj! coll)
-> coll. conj! onto a transient map accepts a [k v] pair or a map (merge), and
throws on a list/set/seq.

pop_bang/dissoc_bang clean; conj_bang 13/1/22->47/3/1; persistent_bang 9/8->16/1.
clojure-test-suite pass 3781->3824. spec: transient/strictness (10). jpm test green.
This commit is contained in:
Yogthos 2026-06-05 11:09:38 -04:00
parent fb36577ee7
commit a4a48a8520
3 changed files with 43 additions and 14 deletions

View file

@ -18,7 +18,7 @@
# Baseline: assertions Jolt currently passes across the suite. Raise as Jolt
# improves so a regression (previously-passing assertion breaking) is caught.
(def baseline-pass 3770)
(def baseline-pass 3820)
# A file is "clean" when it ran with zero failures AND zero errors.
(def baseline-clean-files 45)
# Per-file wall-clock budget (seconds). Normal files finish in well under 1s;

View file

@ -76,3 +76,17 @@
["persistent! twice" :throws
"(let [t (transient [])] (persistent! t) (persistent! t))"]
["pop! empty" :throws "(pop! (transient []))"])
# The bang ops require an appropriate transient (Clojure throws otherwise);
# conj! has the special 0-/1-arg identity arities.
(defspec "transient / strictness"
["conj! on persistent" :throws "(conj! [1 2] 3)"]
["assoc! on persistent" :throws "(assoc! {:a 1} :b 2)"]
["persistent! on vector" :throws "(persistent! [1 2])"]
["persistent! on nil" :throws "(persistent! nil)"]
["pop! on transient map" :throws "(pop! (transient {:a 1}))"]
["dissoc! on tset" :throws "(dissoc! (transient #{1}) 1)"]
["conj! map bad item" :throws "(conj! (transient {}) (list :a 1))"]
["conj! no args" "[]" "(persistent! (conj!))"]
["conj! identity" "[1 2]" "(conj! [1 2])"]
["conj! map merges map" "{:a 1, :b 2}" "(persistent! (conj! (transient {:a 1}) {:b 2}))"])