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.
This commit is contained in:
Yogthos 2026-06-21 17:11:15 -04:00
parent 547a8c6d17
commit 45596d7239
2 changed files with 23 additions and 2 deletions

View file

@ -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)

View file

@ -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"