core: enforce fn arity in both modes (jolt-6xn); canonical seq-to-map-for-destructuring

Fixed arities now throw Clojure's ArityException shape — 'Wrong number of
args (N) passed to: name' — on any count mismatch; variadic arities on fewer
than their fixed params. The compiled path already enforced fixed arities via
janet's native fn check and multi-arity dispatch; this adds the check to the
interpreter's single-arity closures (the oracle was silently dropping extra
args and giving a raw tuple-index error for missing ones) and guards the
compiled single-variadic wrapper's minimum. Messages carry the fn name when
there is one. 16 spec rows; the update.cljc suite row flipped green (4703 ->
4704).

Enforcement exposed that seq-to-map-for-destructuring had drifted: the spec
row called the 1-arity fn with two args, and the body silently dropped a
trailing unpaired element. Replaced with the canonical Clojure 1.11 version
(even pairs build the map, a single trailing element passes through — so
(f {:b 2}) kwargs calls work — and an unpaired key throws).

Also: transients RFC notes tuple support from the seed-shrink rounds.
This commit is contained in:
Yogthos 2026-06-11 16:20:14 -04:00
parent 501c6bf9c9
commit 9e9fd19450
6 changed files with 66 additions and 12 deletions

View file

@ -528,15 +528,21 @@
(fn* [] (coll->cells (cons (first s) (step (rest s) (first s))))))
()))))
;; Internal helper for {:keys [...]} destructuring over a seq of k/v pairs:
;; builds a map from consecutive pairs, dropping a trailing unpaired element.
;; Internal helper for {:keys [...]} destructuring over a seq of k/v pairs —
;; canonical Clojure 1.11 shape (core.clj seq-to-map-for-destructuring):
;; even pairs build a map (later keys win, as createAsIfByAssoc), a SINGLE
;; element is returned as-is (the trailing-map calling convention), and an
;; unpaired key past pairs throws. The old jolt version silently dropped the
;; trailing element, losing (f {:b 2}) kwargs calls.
(defn seq-to-map-for-destructuring [s]
(if (sequential? s)
(if (next s)
(loop [m {} xs (seq s)]
(if (and xs (next xs))
(recur (assoc m (first xs) (second xs)) (next (next xs)))
(if xs
(if (next xs)
(recur (assoc m (first xs) (second xs)) (nnext xs))
(throw (str "No value supplied for key: " (first xs))))
m))
s))
(if (seq s) (first s) {})))
;; Phase 4 (jolt-1j0): host-coupled fns that are pure logic over existing core
;; primitives, so they need no new jolt.host surface.