Fix seed assoc! to throw on odd args (jolt-ea9k)

The transient assoc! accepted an odd key/val count and silently assigned
nil to the dangling key — non-Clojure, and inconsistent with the seed's
own plain assoc (which throws) and Clojure's assoc!. Make it throw.

Updates the 4 'assoc! odd args' transient spec rows to 3 :throws + 1
even-args positive, and regenerates corpus.edn. The Chez host already
threw on these, so this only realigns the corpus contract.
This commit is contained in:
Yogthos 2026-06-18 03:27:21 -04:00
parent d7420deecb
commit 6cc3dc2c7f
3 changed files with 19 additions and 23 deletions

View file

@ -402,11 +402,13 @@
(error "conj! requires a transient")))))
(defn core-assoc! [t & kvs]
# Unlike assoc, assoc! accepts an ODD number of args — a missing final value
# is taken as nil (so (get kvs (+ i 1)) rather than (in ...), which would
# error on the dangling key).
# assoc! requires an even key/val count, like assoc and Clojure's assoc! — a
# dangling key with no value throws (jolt-ea9k: the former lenient nil-fill
# was non-Clojure and inconsistent with jolt's own plain assoc).
(when (odd? (length kvs))
(error "assoc! expects an even number of key/value arguments"))
(if (core-transient? t)
(do (var i 0) (while (< i (length kvs)) (tr-assoc! t (in kvs i) (get kvs (+ i 1))) (+= i 2)) t)
(do (var i 0) (while (< i (length kvs)) (tr-assoc! t (in kvs i) (in kvs (+ i 1))) (+= i 2)) t)
(error "assoc! requires a transient")))
(defn core-dissoc! [t & ks]