Resolve :use/:only refers, refer-aware syntax-quote, alias-aware resolve
Three related namespace-resolution fixes surfaced porting the clojure.tools.logging library, all general: - chez-register-spec! treats a :use :only vector like :require :refer, so a (:use [ns :only [names]]) clause actually brings those names in. Before, a bare reference to an :only'd name resolved to nil. - syntax-quote (hc-sq-symbol) qualifies a referred name to its SOURCE namespace, not the compile namespace — so a macro that syntax-quotes a referred var (e.g. clojure.tools.logging/spy reaching clojure.pprint's pprint) expands correctly. - resolve consults :as aliases and :refers like ns-resolve does; (resolve 'alias/name) was returning nil because the alias wasn't expanded.
This commit is contained in:
parent
45876998ad
commit
ccf93c896a
2 changed files with 17 additions and 4 deletions
|
|
@ -225,6 +225,12 @@
|
|||
((hc-special-symbol? nm) form) ; special form: leave bare
|
||||
((hc-interop-head? nm) form) ; interop (.method / Class. / .-field): bare
|
||||
((var-cell-lookup "clojure.core" nm) (jolt-symbol "clojure.core" nm))
|
||||
;; a name referred into the compile ns (:require :refer / :use :only)
|
||||
;; qualifies to its SOURCE ns, not the compile ns — so a macro that
|
||||
;; syntax-quotes a referred var (e.g. clojure.tools.logging/spy using
|
||||
;; clojure.pprint's pprint) expands to the real var.
|
||||
((chez-resolve-refer (chez-actx-cns ctx) nm)
|
||||
=> (lambda (target) (jolt-symbol target nm)))
|
||||
(else (jolt-symbol (chez-actx-cns ctx) nm))) ; else: qualify to compile ns
|
||||
;; qualified: if the ns part is an :as alias in the compile ns, resolve it
|
||||
;; to the target namespace — Clojure resolves the alias part of a qualified
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue