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:
parent
f856c16f06
commit
b4d9eaa527
4 changed files with 114 additions and 99 deletions
|
|
@ -377,6 +377,14 @@
|
|||
;; value, not the raw tagged form). Same emit as the :inst / :uuid IR leaves.
|
||||
(form-inst? form) (str "(jolt-inst-from-string " (chez-str-lit (form-inst-source form)) ")")
|
||||
(form-uuid? form) (str "(jolt-uuid-from-string " (chez-str-lit (form-uuid-source form)) ")")
|
||||
;; a quoted custom #tag with no registered reader -> a tagged-literal value
|
||||
;; (Clojure's reader builds a TaggedLiteral), not the raw reader map. The tag is
|
||||
;; stored as a :#name keyword; strip the leading # to the bare symbol.
|
||||
(and (map? form) (= :jolt/tagged (get form :jolt/type)))
|
||||
(let [nm (name (get form :tag))
|
||||
tsym (if (= \# (first nm)) (subs nm 1) nm)]
|
||||
(str "(jolt-tagged-literal (jolt-symbol #f " (chez-str-lit tsym) ") "
|
||||
(emit-quoted (get form :form)) ")"))
|
||||
;; plain jolt VALUES (metadata maps and anything nested in them)
|
||||
(map? form) (emit-quoted-map-value form)
|
||||
(vector? form) (str "(jolt-vector " (str/join " " (map emit-quoted form)) ")")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue