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:
parent
1008e922d8
commit
908ad63caa
10 changed files with 88 additions and 8 deletions
1
test/chez/datareader-app/deps.edn
Normal file
1
test/chez/datareader-app/deps.edn
Normal file
|
|
@ -0,0 +1 @@
|
|||
{:paths ["src"]}
|
||||
1
test/chez/datareader-app/src/data_readers.clj
Normal file
1
test/chez/datareader-app/src/data_readers.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
{code drtest.reader/code-reader}
|
||||
4
test/chez/datareader-app/src/drtest/main.clj
Normal file
4
test/chez/datareader-app/src/drtest/main.clj
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(ns drtest.main
|
||||
(:require drtest.reader))
|
||||
(defn -main [& _]
|
||||
(println #code [:ignored]))
|
||||
2
test/chez/datareader-app/src/drtest/reader.clj
Normal file
2
test/chez/datareader-app/src/drtest/reader.clj
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(ns drtest.reader)
|
||||
(defn code-reader [_form] (list '+ 40 2))
|
||||
Loading…
Add table
Add a link
Reference in a new issue