From f625099ddf6837b06b05c297f5bdd701b6777f9f Mon Sep 17 00:00:00 2001 From: Yogthos Date: Tue, 30 Jun 2026 23:05:04 -0400 Subject: [PATCH] fix `clojure.core/max` shadowed by a local --- host/chez/host-contract.ss | 7 ++++++- host/chez/seed/image.ss | 2 +- host/chez/seed/prelude.ss | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/host/chez/host-contract.ss b/host/chez/host-contract.ss index 13b596e..d50bd4b 100644 --- a/host/chez/host-contract.ss +++ b/host/chez/host-contract.ss @@ -184,7 +184,12 @@ ;; a qualified ns may be a require :as alias (s/split -> clojure.string/split) (let ((target (or (chez-resolve-alias (chez-actx-cns ctx) qualified) qualified))) (var-cell-lookup target nm)) - (or (var-cell-lookup (chez-actx-cns ctx) nm) + (or (let ((c (var-cell-lookup (chez-actx-cns ctx) nm))) + ;; an undefined forward-intern must not shadow a real referred + ;; or clojure.core var — e.g. the compiler ns referencing `set`, + ;; which late-binds (interns `jolt.backend-scheme/set` undefined) + ;; and would otherwise hide clojure.core/set on the mint fixpoint. + (and c (var-cell-defined? c) c)) ;; a :refer'd name resolves to its source ns (let ((ref (chez-resolve-refer (chez-actx-cns ctx) nm))) (and ref (var-cell-lookup ref nm))) diff --git a/host/chez/seed/image.ss b/host/chez/seed/image.ss index 13e99f7..6143eb9 100644 --- a/host/chez/seed/image.ss +++ b/host/chez/seed/image.ss @@ -189,7 +189,7 @@ (guard (e (#t #f)) (def-var-with-meta! "jolt.backend-scheme" "scheme-reserved" (let* ((_o$7642 "if") (_o$7643 "begin") (_o$7644 "lambda") (_o$7645 "let") (_o$7646 "let*") (_o$7647 "letrec") (_o$7648 "letrec*") (_o$7649 "quote") (_o$7650 "quasiquote") (_o$7651 "unquote") (_o$7652 "set!") (_o$7653 "define") (_o$7654 "define-syntax") (_o$7655 "cond") (_o$7656 "case") (_o$7657 "when") (_o$7658 "unless") (_o$7659 "and") (_o$7660 "or") (_o$7661 "do") (_o$7662 "else") (_o$7663 "guard") (_o$7664 "parameterize") (_o$7665 "delay") (_o$7666 "values")) (jolt-hash-set _o$7642 _o$7643 _o$7644 _o$7645 _o$7646 _o$7647 _o$7648 _o$7649 _o$7650 _o$7651 _o$7652 _o$7653 _o$7654 _o$7655 _o$7656 _o$7657 _o$7658 _o$7659 _o$7660 _o$7661 _o$7662 _o$7663 _o$7664 _o$7665 _o$7666)) (let* ((_o$7667 (keyword #f "private")) (_o$7668 #t)) (jolt-hash-map _o$7667 _o$7668)))) (guard (e (#t #f)) - (def-var-with-meta! "jolt.backend-scheme" "bare-native-names" (jolt-invoke (var-deref "jolt.backend-scheme" "set") (jolt-invoke (var-deref "clojure.core" "keep") (lambda (G__138) (let fnrec7669 ((G__138 G__138)) (let* ((G__139 G__138) (k (jolt-nth G__139 0 jolt-nil)) (v (jolt-nth G__139 1 jolt-nil))) (if (jolt= k v) k jolt-nil)))) (var-deref "jolt.backend-scheme" "native-ops"))) (let* ((_o$7670 (keyword #f "private")) (_o$7671 #t)) (jolt-hash-map _o$7670 _o$7671)))) + (def-var-with-meta! "jolt.backend-scheme" "bare-native-names" (jolt-invoke (var-deref "clojure.core" "set") (jolt-invoke (var-deref "clojure.core" "keep") (lambda (G__138) (let fnrec7669 ((G__138 G__138)) (let* ((G__139 G__138) (k (jolt-nth G__139 0 jolt-nil)) (v (jolt-nth G__139 1 jolt-nil))) (if (jolt= k v) k jolt-nil)))) (var-deref "jolt.backend-scheme" "native-ops"))) (let* ((_o$7670 (keyword #f "private")) (_o$7671 #t)) (jolt-hash-map _o$7670 _o$7671)))) (guard (e (#t #f)) (def-var-with-meta! "jolt.backend-scheme" "munge-name" (letrec ((munge-name (lambda (s) (let fnrec7672 ((s s)) (let* ((s (jolt-invoke (var-deref "clojure.string" "replace") (jolt-invoke (var-deref "clojure.string" "replace") s "#" "_") "'" "_PRIME_"))) (if (let* ((or__26__auto (jolt-contains? (var-deref "jolt.backend-scheme" "scheme-reserved") s))) (if (jolt-truthy? or__26__auto) or__26__auto (jolt-contains? (var-deref "jolt.backend-scheme" "bare-native-names") s))) (jolt-invoke (var-deref "clojure.core" "str") "_" s) s)))))) munge-name) (let* ((_o$7673 (keyword #f "private")) (_o$7674 #t)) (jolt-hash-map _o$7673 _o$7674)))) (guard (e (#t #f)) diff --git a/host/chez/seed/prelude.ss b/host/chez/seed/prelude.ss index 11549c3..3fe8c8d 100644 --- a/host/chez/seed/prelude.ss +++ b/host/chez/seed/prelude.ss @@ -487,9 +487,9 @@ (guard (e (#t #f)) (def-var! "clojure.core" "trampoline" (letrec ((trampoline (case-lambda ((f) (let fnrec4585 ((f f)) (let* ((ret (jolt-invoke f))) (if (jolt-truthy? (jolt-invoke (var-deref "clojure.core" "fn?") ret)) (trampoline ret) ret)))) ((f . args) (let fnrec4586 ((f f) (args (list->cseq args))) (trampoline (lambda () (let fnrec4587 () (jolt-apply f args))))))))) trampoline))) (guard (e (#t #f)) - (def-var! "clojure.core" "max" (letrec ((max (case-lambda ((x) (let fnrec4588 ((x x)) x)) ((x y) (let fnrec4589 ((x x) (y y)) (if (> x y) x y))) ((x y . more) (let fnrec4590 ((x x) (y y) (more (list->cseq more))) (jolt-reduce max (max x y) more)))))) max))) + (def-var! "clojure.core" "max" (letrec ((_max (case-lambda ((x) (let fnrec4588 ((x x)) x)) ((x y) (let fnrec4589 ((x x) (y y)) (if (> x y) x y))) ((x y . more) (let fnrec4590 ((x x) (y y) (more (list->cseq more))) (jolt-reduce _max (_max x y) more)))))) _max))) (guard (e (#t #f)) - (def-var! "clojure.core" "min" (letrec ((min (case-lambda ((x) (let fnrec4591 ((x x)) x)) ((x y) (let fnrec4592 ((x x) (y y)) (if (< x y) x y))) ((x y . more) (let fnrec4593 ((x x) (y y) (more (list->cseq more))) (jolt-reduce min (min x y) more)))))) min))) + (def-var! "clojure.core" "min" (letrec ((_min (case-lambda ((x) (let fnrec4591 ((x x)) x)) ((x y) (let fnrec4592 ((x x) (y y)) (if (< x y) x y))) ((x y . more) (let fnrec4593 ((x x) (y y) (more (list->cseq more))) (jolt-reduce _min (_min x y) more)))))) _min))) (guard (e (#t #f)) (def-var! "clojure.core" "reverse" (letrec ((reverse (lambda (coll) (let fnrec4594 ((coll coll)) (jolt-reduce jolt-conj (jolt-list ) coll))))) reverse))) (guard (e (#t #f))