(defn var-ast
[env sym]
;; we need to dissoc locals for the `(let [x 1] (def x x))` case, because we
;; want the var's AST and `resolve-var` will check locals first. - António Monteiro
(let [env (dissoc env :locals)
var (resolve-var env sym (confirm-var-exists-throw))
expr-env (assoc env :context :expr)]
(when-some [var-ns (:ns var)]
{:var (analyze expr-env sym)
:sym (analyze expr-env `(quote ~(symbol (name var-ns) (name (:name var)))))
:meta (var-meta var expr-env)})))