clj-commons / potemkin

some ideas which are almost good
577 stars 53 forks source link

remove metadata from var name obtained via (:name (meta v)) #20

Closed Bronsa closed 10 years ago

Bronsa commented 10 years ago

when the def sym obtained via (:name (meta v)) has metadata (which is the case when analyzed via tools.analyzer for instance) potemkin will evaluate the var metadata unquoted, resulting in errors.

ztellman commented 10 years ago

Can you give me a test case for this?

Bronsa commented 10 years ago

Eh, it's a bit hard to reproduce this behaviour using the clojure compiler since because of how the compiler implements it, (-> some-var meta :name meta) will always be nil.

If you want to make sure of this let me know and I'll point you to the code in the clojure source where you can see how this is true.

One way to artificially get the error is to manually attach some meta to the :name symbol:

user=> (defn a [b])
#'user/a
user=> (alter-meta! #'a update-in [:name] vary-meta merge (meta #'a))
{:arglists ([b]), :ns #<Namespace user>, :name a, :column 1, :line 1, :file "/tmp/form-init7296519293118895482.clj"}
user=> (ns foo)
nil
foo=> (use 'potemkin)
nil
foo=> (import-def user/a)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(/tmp/form-init7296519293118895482.clj:1:1)