edn: apply tag readers inside a set literal
clojure.edn/read with :readers/:default recursed into vectors/maps/seqs but
not a constructed set, so a tagged literal in #{…} (aero's #ref in a set) kept
its raw form. edn->value now recurses into a set. clojure.edn is baked into the
seed, re-minted. Fixes aero #ref-in-set + falsey-user-return.
This commit is contained in:
parent
eb64240e29
commit
afc733a439
4 changed files with 739 additions and 734 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -36,6 +36,9 @@
|
|||
(map? x)
|
||||
(with-meta (into {} (map (fn [e] [(edn->value opts (key e)) (edn->value opts (val e))]) x)) (meta x))
|
||||
(vector? x) (with-meta (mapv (fn [v] (edn->value opts v)) x) (meta x))
|
||||
;; a constructed set: recurse into its elements too, so a tagged literal
|
||||
;; inside #{…} gets the :readers/:default treatment (aero's #ref in a set).
|
||||
(set? x) (with-meta (set (map (fn [v] (edn->value opts v)) x)) (meta x))
|
||||
(seq? x) (with-meta (map (fn [v] (edn->value opts v)) x) (meta x))
|
||||
:else x))
|
||||
|
||||
|
|
|
|||
|
|
@ -3306,4 +3306,6 @@
|
|||
{:suite "reader / metadata" :label "metadata on an empty list is preserved" :expected "true" :actual "(= {:foo 1} (meta (read-string \"^{:foo 1} ()\")))"}
|
||||
{:suite "reader / metadata" :label "a vector in metadata reads as a value" :expected "true" :actual "(= [1 2] (:v (meta (read-string \"^{:v [1 2]} {:a 1}\"))))"}
|
||||
{:suite "reader / metadata" :label "an empty list in metadata reads as a value" :expected "true" :actual "(= () (:e (meta (read-string \"^{:e ()} [1]\"))))"}
|
||||
{:suite "edn / readers in collections" :label "a :default tag reader applies inside a set" :expected "true" :actual "(= #{[:t 1]} (clojure.edn/read-string {:default (fn [t v] [:t v])} \"#{#foo 1}\"))"}
|
||||
{:suite "edn / readers in collections" :label "a registered reader applies inside a set" :expected "true" :actual "(= #{6} (clojure.edn/read-string {:readers {(quote x) (fn [v] (* v 2))}} \"#{#x 3}\"))"}
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue