From f15a4e77476488bed732ff6eafa9ce92e38fbc19 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Sun, 21 Jun 2026 17:46:20 -0400 Subject: [PATCH] reduce dispatches to a reify's IReduceInit reduce method (jolt-z1zu) (reduce f init (reify clojure.lang.IReduceInit (reduce [_ f i] ...))) tried to seq the reify and threw 'not seqable'. When the coll is a reify carrying a reduce method, drive the reduction through it. Corpus 2693->2694. --- host/chez/run-corpus.ss | 4 ++-- host/chez/seq.ss | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/host/chez/run-corpus.ss b/host/chez/run-corpus.ss index b2ea706..3aa2e28 100644 --- a/host/chez/run-corpus.ss +++ b/host/chez/run-corpus.ss @@ -11,7 +11,7 @@ ;; reset between cases so there is no leakage — same isolation a fresh process gives. ;; ;; chez --script host/chez/run-corpus.ss -;; JOLT_CHEZ_ZJ_FLOOR=N override the regression floor (default 2693) +;; JOLT_CHEZ_ZJ_FLOOR=N override the regression floor (default 2694) ;; JOLT_CORPUS_LIMIT=N every-Nth stride (fast iteration; floor drops to 0) ;; JOLT_DUMP_CRASH_LABELS=1 list crash + allowlisted labels (import (chezscheme)) @@ -203,7 +203,7 @@ ;; Regression floor: fail on any NEW divergence or if pass drops below the floor. (define base-floor (let ((s (getenv "JOLT_CHEZ_ZJ_FLOOR"))) - (if s (string->number s) 2693))) + (if s (string->number s) 2694))) (define floor (if limit 0 base-floor)) (when (or (> (length diverged) 0) (< pass floor)) (printf "REGRESSION: pass ~a < floor ~a or ~a new divergence(s)\n" diff --git a/host/chez/seq.ss b/host/chez/seq.ss index dd2ed99..d1acc72 100644 --- a/host/chez/seq.ss +++ b/host/chez/seq.ss @@ -178,7 +178,15 @@ ((f coll) (let ((s (jolt-seq coll))) (if (jolt-nil? s) (jolt-invoke f) ; (reduce f []) -> (f) (reduce-seq f (seq-first s) (jolt-seq (seq-more s)))))) - ((f init coll) (reduce-seq f init (jolt-seq coll))))) + ((f init coll) + ;; IReduceInit: a reify/record with its own `reduce` method drives the + ;; reduction (reduce f init (reify clojure.lang.IReduceInit (reduce [_ f i] ...))). + (cond + ((and (jreify? coll) (reified-methods coll) + (hashtable-ref (reified-methods coll) "reduce" #f)) + => (lambda (m) (let ((r (jolt-invoke m coll f init))) + (if (jolt-reduced? r) (jolt-reduced-val r) r)))) + (else (reduce-seq f init (jolt-seq coll))))))) (define (jolt-into to from) (reduce-seq (lambda (acc x) (jolt-conj1 acc x)) to (jolt-seq from)))