I came across a possible issue with the :postprocess
option regarding metadata. Not sure if this is a :postprocess
thing is deeper in edamame
. I have the following parser:
(defn my-parser [s]
(e/parse-string s {:postprocess
(fn [{:keys [obj]}]
(if (keyword? obj)
{:value obj}
obj))}))
All I'm doing is wrapping the obj
in a map if it is a keyword. But the follow clauses are returning different results now:
(defn variable-meta [ast]
(-> ast second meta))
(-> "(def ^:dynamic some-var 1)"
my-parser
variable-meta)
;; => {:value :dynamic}
(-> "(def ^{:dynamic true} some-var 1)"
my-parser
variable-meta)
;; => {{:value :dynamic} true}
All I'm doing is defining some-var
and getting the metadata out of it. Attaching the metadata in a different way. But ^:dynamic
should be a shorthand for ^{:dynamic true}
. So I would expect both clauses to return the same. (n this scenario, I'd expect both to return the last clause
{{:value :dynamic} true}
This is an issue for me because I'm wrapping non IMeta objects in a record. I didn't except ^:dynamic
to be part of this process. I can work around this but I find it strange that these two clauses return different results