I have two somewhat related problems, shown by the following:
user=> (if (symbol? 5) (meta (var 5)) 5)
CompilerException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:6)
user=> (defn dometa [x] (if (symbol? x) (meta (var x)) x))
CompilerException java.lang.RuntimeException: Unable to resolve var: x in this context, compiling:(NO_SOURCE_PATH:7)
user=>
In the first case, since 5 is not a symbol I would not expect (meta (var 5)) to be evaluated, but it is (or at least that’s the way it seems to me).
In the second case, if I want to place the first expression in a function, and parameterize the value being tested, the (var …) function no longer works.
The Var object is looked up at compile time. For the behaviour I’m inferring from your examples, you should use
find-var.