From 45596d72392a0005dec90415775f9878a909eb64 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Sun, 21 Jun 2026 17:11:15 -0400 Subject: [PATCH] import: bring a cross-ns deftype/record ctor into the current ns (jolt-c2l1) (:import [other.ns Type]) was a no-op (import unbound), so (Type. ...) failed with 'Unknown class'. Bind import to register each named type's ctor closure under the current ns. Corpus 2691->2692. --- host/chez/natives-str.ss | 21 +++++++++++++++++++++ host/chez/run-corpus.ss | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/host/chez/natives-str.ss b/host/chez/natives-str.ss index d359010..a036d2f 100644 --- a/host/chez/natives-str.ss +++ b/host/chez/natives-str.ss @@ -307,3 +307,24 @@ specs) jolt-nil) (def-var! "clojure.core" "use" chez-runtime-use) +;; import: bring a deftype/defrecord from another ns into the current one. A spec +;; [from-ns Type ...] binds each Type's ctor closure under the current ns, so its +;; (Type. ...) constructor (host-new resolves it as a var) works after :import. +(define (chez-runtime-import . specs) + (for-each + (lambda (spec) + (let ((items (cond ((pvec? spec) (seq->list spec)) + ((or (cseq? spec) (empty-list-t? spec)) (seq->list spec)) + (else '())))) + (when (and (pair? items) (symbol-t? (car items))) + (let ((from (symbol-t-name (car items)))) + (for-each + (lambda (tn) + (when (symbol-t? tn) + (let ((c (var-cell-lookup from (symbol-t-name tn)))) + (when (and c (var-cell-defined? c)) + (def-var! (chez-current-ns) (symbol-t-name tn) (var-cell-root c)))))) + (cdr items)))))) + specs) + jolt-nil) +(def-var! "clojure.core" "import" chez-runtime-import) diff --git a/host/chez/run-corpus.ss b/host/chez/run-corpus.ss index fc7df33..50220da 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 2691) +;; JOLT_CHEZ_ZJ_FLOOR=N override the regression floor (default 2692) ;; 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) 2691))) + (if s (string->number s) 2692))) (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"