From bfb49f23ab1fa0d956ec4be2f17b60fbae6b8d56 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Sat, 6 Jun 2026 19:28:47 -0400 Subject: [PATCH] core: multi-collection map handles nil elements in a lazy-seq input (jolt-dzh) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The multi-coll map step detected end-of-seq with (nil? (ls-first cur)), which also fired on a legitimate nil element — so mapping over a lazy-seq containing nils truncated at the first nil. That's why (doall (map merge a b)) collapsed to () as a reduce accumulator. Use seq-done? to detect exhaustion and push the value (which may be nil). doall is unchanged; clojure.data restored to the canonical (doall (map ...)) form. Conformance 218/218; battery 3919. --- src/jolt/clojure/data.clj | 15 ++++++--------- src/jolt/core.janet | 11 +++++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/jolt/clojure/data.clj b/src/jolt/clojure/data.clj index 9d79c67..cfc0456 100644 --- a/src/jolt/clojure/data.clj +++ b/src/jolt/clojure/data.clj @@ -44,18 +44,15 @@ "Diff associative things a and b, comparing only keys in ks." [a b ks] (reduce - ;; mapv (eager) rather than the reference's (doall (map …)): jolt's - ;; multi-collection map is lazy and doesn't force reliably as a reduce - ;; accumulator here. - (fn [diff1 diff2] (mapv merge diff1 diff2)) + (fn [diff1 diff2] (doall (map merge diff1 diff2))) [nil nil nil] - (mapv (partial diff-associative-key a b) ks))) + (map (partial diff-associative-key a b) ks))) (defn- diff-sequential [a b] - (vec (mapv vectorize (diff-associative - (if (vector? a) a (vec a)) - (if (vector? b) b (vec b)) - (range (max (count a) (count b))))))) + (vec (map vectorize (diff-associative + (if (vector? a) a (vec a)) + (if (vector? b) b (vec b)) + (range (max (count a) (count b))))))) (defn- diff-set [a b] [(not-empty (set/difference a b)) diff --git a/src/jolt/core.janet b/src/jolt/core.janet index 1580f02..884a744 100644 --- a/src/jolt/core.janet +++ b/src/jolt/core.janet @@ -834,12 +834,15 @@ (while (< i (length cs)) (let [cur (in cs i) ridx (in idxs i) real (in reals i)] (if (not (nil? cur)) - (let [val (ls-first cur)] - (if (nil? val) (do (set ok false) (break)) - (do (array/push args val) + # Detect exhaustion with seq-done?, NOT (nil? (ls-first)): a + # lazy-seq can legitimately contain nil elements, and treating the + # first nil as end-of-seq truncates (e.g. mapping over a previous + # map result that holds nils). + (if (seq-done? cur) (do (set ok false) (break)) + (do (array/push args (ls-first cur)) (put next-cs i (ls-rest cur)) (put next-idxs i (+ ridx 1)) - (put next-reals i nil)))) + (put next-reals i nil))) (let [c (if (nil? real) (let [rc (realize-for-iteration (in colls i))] (put next-reals i rc) rc)