Compile data readers that return code forms

A registered #tag data reader whose fn returns a FORM (borkdude/html's #html
expands to (->Html (str …))) was rewritten to a runtime call (reader-fn 'inner),
so the returned code became a runtime list value instead of being compiled —
(str #html [:div]) rendered the code, not "<div>". Clojure applies a data reader
at read time and substitutes its result as code.

loader.ss now applies the reader at load time: a code form (a list) is spliced in
to be compiled, a value (time-literals #time/date -> a Date) keeps the runtime
call, which also keeps a non-serializable constant out of an AOT build. The build
emit path never applied data readers at all (a #tag literal failed a `jolt build`
with "unsupported form"); emit-image.ss gets an ei-emit-form-hook the build sets
to the same rewrite, left as a no-op elsewhere so the seed mint (which doesn't
load loader.ss) is unaffected and the self-host byte-fixpoint holds.

Also make clojure.test report the actual values of a failing (is (= a b)) — it
printed only the form. Restricted to the common pure predicates so a macro head
still takes the plain path.

Fixture test/chez/datareader-app + a smoke check (interpreted) and a build-smoke
check (AOT). make test green, no corpus change.
This commit is contained in:
Yogthos 2026-07-01 10:57:55 -04:00
parent 1008e922d8
commit 908ad63caa
10 changed files with 88 additions and 8 deletions

View file

@ -0,0 +1 @@
{:paths ["src"]}

View file

@ -0,0 +1 @@
{code drtest.reader/code-reader}

View file

@ -0,0 +1,4 @@
(ns drtest.main
(:require drtest.reader))
(defn -main [& _]
(println #code [:ignored]))

View file

@ -0,0 +1,2 @@
(ns drtest.reader)
(defn code-reader [_form] (list '+ 40 2))