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
|
|
@ -116,4 +116,17 @@ fi
|
|||
if grep -q 'def-var! "clojure.core" "group-by"' "$out.build/flat.ss"; then
|
||||
echo " FAIL: --tree-shake kept an unreachable clojure.core fn (group-by)"; exit 1
|
||||
fi
|
||||
echo "build smoke: passed (release + optimized + direct-link + tree-shake + compiler+core shake)"
|
||||
# A registered data reader that returns a CODE form must be compiled into the
|
||||
# binary (the emit path applies it too, not just the interpreted loader): the
|
||||
# datareader-app's #code literal builds to 42, not the literal list.
|
||||
drapp="$root/test/chez/datareader-app"
|
||||
drout="$(dirname "$out")/dr-bin"
|
||||
if ! JOLT_PWD="$drapp" bin/joltc build -m drtest.main -o "$drout" >/dev/null 2>&1; then
|
||||
echo " FAIL: jolt build of a data-reader app exited non-zero"; exit 1
|
||||
fi
|
||||
got_dr="$(cd / && "$drout" 2>&1 | tail -1)"
|
||||
if [ "$got_dr" != "42" ]; then
|
||||
echo " FAIL: built #code data reader — want 42, got \`$got_dr\`"; exit 1
|
||||
fi
|
||||
|
||||
echo "build smoke: passed (release + optimized + direct-link + tree-shake + compiler+core shake + data-reader)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue