Read an unknown #tag as a tagged-literal value

An unknown reader tag produced the reader's internal form
{:jolt/type :jolt/tagged :tag :#foo :form bar}, which tagged-literal? didn't
recognize and which leaked as a raw map when printed:

  (tagged-literal? (read-string "#foo bar"))  => false   ; want true
  (pr-str (quote [#foo bar]))                 => "[{:jolt/type :jolt/tagged ...}]"

Both the data path (rdr-construct-tag) and the compile path (emit-quoted) now
build a real tagged-literal for a tag with no registered reader, like Clojure's
*default-data-reader-fn*, so tagged-literal? / :tag / :form / printing all work.
clojure.edn reads raw forms through a separate __read-form-raw path and applies
:readers/:default itself, so it is unaffected.

Re-mint (backend + reader are seed sources); prelude byte-identical, image only.
make test green (selfhost holds, 0 new/stale), +2 unit rows.
This commit is contained in:
Yogthos 2026-07-01 16:17:52 -04:00
parent f856c16f06
commit b4d9eaa527
4 changed files with 114 additions and 99 deletions

View file

@ -748,7 +748,12 @@
(if fn (jolt-invoke fn inner)
(let ((dfn (rdr-default-data-reader-fn)))
(if dfn (jolt-invoke dfn (rdr-tag->symbol tag) inner)
(rdr-make-tagged tag inner))))))))
;; no reader for the tag: a proper tagged-literal value, like
;; Clojure's *default-data-reader-fn* (tagged-literal), so
;; tagged-literal? / :tag / :form / printing all work — not the
;; internal reader form. clojure.edn reads raw forms via
;; __read-form-raw, so its :readers/:default path is unaffected.
(jolt-tagged-literal (rdr-tag->symbol tag) inner))))))))
;; rdr-form->data*: convert the VALUE structure (set/tagged/nested forms). The
;; wrapper below adds the metadata, so the unchanged branches return x bare.

File diff suppressed because one or more lines are too long