(type record) returns its class-name string, not a symbol

(type r) returned a symbol user.TyR, so (= (symbol (str (type r))) (type r))
was true; the JVM's type is a Class (not a Symbol) so it's false. jolt models
classes as strings, so a record's type is now its ns-qualified class-name
string — equal to (class r), as on the JVM where type and class coincide for a
record. The symbol-keyed print-method defmethods already fall through to the
default record printing, so they're unaffected. Closes type-of-record.
This commit is contained in:
Yogthos 2026-06-22 00:05:08 -04:00
parent ab96650fbb
commit 0e4ccc97e0
3 changed files with 9 additions and 8 deletions

View file

@ -79,9 +79,10 @@
(override (if (jolt-nil? m) jolt-nil (jolt-get m ty-kw-type jolt-nil)))) (override (if (jolt-nil? m) jolt-nil (jolt-get m ty-kw-type jolt-nil))))
(cond (cond
((not (jolt-nil? override)) override) ; :type meta wins ((not (jolt-nil? override)) override) ; :type meta wins
;; record -> ns.Name symbol. No-ns sentinel is #f (not jolt-nil) so it = the ;; record -> its ns-qualified class-name STRING (= (class x)). jolt models
;; overlay's (symbol (str t)) — jolt= compares the ns field with equal?. ;; classes as strings, so (symbol (str (type r))) is NOT (type r) — as on the
((jrec? x) (jolt-symbol #f (jrec-tag x))) ;; JVM where type is a Class, not a Symbol.
((jrec? x) (jrec-tag x))
((jolt-nil? x) jolt-nil) ((jolt-nil? x) jolt-nil)
((boolean? x) ty-boolean) ((boolean? x) ty-boolean)
((number? x) ty-number) ((number? x) ty-number)

View file

@ -11,7 +11,7 @@
;; reset between cases so there is no leakage — same isolation a fresh process gives. ;; reset between cases so there is no leakage — same isolation a fresh process gives.
;; ;;
;; chez --script host/chez/run-corpus.ss ;; chez --script host/chez/run-corpus.ss
;; JOLT_CHEZ_ZJ_FLOOR=N override the regression floor (default 2726) ;; JOLT_CHEZ_ZJ_FLOOR=N override the regression floor (default 2727)
;; JOLT_CORPUS_LIMIT=N every-Nth stride (fast iteration; floor drops to 0) ;; JOLT_CORPUS_LIMIT=N every-Nth stride (fast iteration; floor drops to 0)
;; JOLT_DUMP_CRASH_LABELS=1 list crash + allowlisted labels ;; JOLT_DUMP_CRASH_LABELS=1 list crash + allowlisted labels
(import (chezscheme)) (import (chezscheme))
@ -87,7 +87,7 @@
;; a NEW (unlisted) divergence or a drop below the floor. ;; a NEW (unlisted) divergence or a drop below the floor.
(define known-fail-labels (define known-fail-labels
'("getMessage on a thrown string" '("getMessage on a thrown string"
"type of record" "chunked-seq? always false" "chunked-seq? always false"
"close on throw" "macroexpand-1" "close on throw" "macroexpand-1"
"bean is the map" "proxy resolves nil" "bean is the map" "proxy resolves nil"
"transient vector" "transient map" "transient vector" "transient map"
@ -189,7 +189,7 @@
;; Regression floor: fail on any NEW divergence or if pass drops below the floor. ;; Regression floor: fail on any NEW divergence or if pass drops below the floor.
(define base-floor (let ((s (getenv "JOLT_CHEZ_ZJ_FLOOR"))) (define base-floor (let ((s (getenv "JOLT_CHEZ_ZJ_FLOOR")))
(if s (string->number s) 2726))) (if s (string->number s) 2727)))
(define floor (if limit 0 base-floor)) (define floor (if limit 0 base-floor))
(when (or (> (length diverged) 0) (< pass floor)) (when (or (> (length diverged) 0) (< pass floor))
(printf "REGRESSION: pass ~a < floor ~a or ~a new divergence(s)\n" (printf "REGRESSION: pass ~a < floor ~a or ~a new divergence(s)\n"

View file

@ -395,8 +395,8 @@
{:suite "type" :expr "(type (with-meta {:a 1} {:type :rec}))" :expected ":rec"} {:suite "type" :expr "(type (with-meta {:a 1} {:type :rec}))" :expected ":rec"}
{:suite "type" :expr "(type (with-meta [1] {:other 9}))" :expected ":vector"} {:suite "type" :expr "(type (with-meta [1] {:other 9}))" :expected ":vector"}
{:suite "type" :expr "(do (defrecord TyR [a]) (type (->TyR 1)))" :expected "user.TyR"} {:suite "type" :expr "(do (defrecord TyR [a]) (type (->TyR 1)))" :expected "user.TyR"}
{:suite "type" :expr "(do (defrecord TyR [a]) (= (symbol (str (type (->TyR 1)))) (type (->TyR 1))))" :expected "true"} {:suite "type" :expr "(do (defrecord TyR [a]) (= (symbol (str (type (->TyR 1)))) (type (->TyR 1))))" :expected "false"}
{:suite "type" :expr "(do (defrecord TyR [a]) (symbol? (type (->TyR 1))))" :expected "true"} {:suite "type" :expr "(do (defrecord TyR [a]) (symbol? (type (->TyR 1))))" :expected "false"}
{:suite "type" :expr "(type (atom 1))" :expected ":jolt/atom"} {:suite "type" :expr "(type (atom 1))" :expected ":jolt/atom"}
{:suite "type" :expr "(type (volatile! 1))" :expected ":jolt/volatile"} {:suite "type" :expr "(type (volatile! 1))" :expected ":jolt/volatile"}
{:suite "type" :expr "(type #\"re\")" :expected ":jolt/regex"} {:suite "type" :expr "(type #\"re\")" :expected ":jolt/regex"}