Open dpsutton opened 2 years ago
I can look at this hopefully when I have some time on the train to ClojureD this week, else next week, but a minimal repro would surely help to look into this faster.
I think I found the issue. When reading, a macro looks like this:
user=> (read-string "(defmacro my-macro [] `(foo))")
(defmacro my-macro [] (clojure.core/seq (clojure.core/concat (clojure.core/list (quote user/foo)))))
and this is the form that grasp "grasps" against. So it is the fully expanded but unevaluated form that the syntax quote gives back.
ah so (list quote user/foo)
won't match against (s/cat :foo ::foo)
spec. Not clear if this a close as not a bug, close as a bug but won't fix, or what. Thank you for looking into it.
@dpsutton This is what the unevaluated form looks like, basically. Always evaluating what comes back from the reader won't work/isn't safe. To find stuff in syntax-quote expression I suggest inspecting them in a REPL:
user=> '`(trs "foobar")
(clojure.core/seq (clojure.core/concat (clojure.core/list (quote user/trs)) (clojure.core/list "foobar")))
and then making your spec account for that.
We could document this.
I wonder if this is a good case for using rewrite-clj to allow descending into unexpanded syntax quotes.
I'm looking for all strings in our codebase at Metabase that need translations. To this end i'm doing
(I only just now realized I can resolve symbols for smarter matching but not relevant here). This spec works great and finds almost all usages. However I've found one that it does not find:
I'm going to try to come up with a minimal reproduction because there's a lot going on.
Note I'm not expecting to find the usage at macro invocations and call sites, just in the literal form here which I would expect it to be able to descend into and match on the
trs
.