diff --git a/CHANGELOG.md b/CHANGELOG.md index ceda18c9..46a934cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Fix issue with `intern` failing when used (#725). * Fix issue with `ns` not being available after `in-ns` on the REPL (#718). * Fixed issue with import modules aliasing using ns eval (#719). + * Fix issue with `ns-resolve` throwing an error on macros (#720). ## [v0.1.0a2] ### Added diff --git a/src/basilisp/lang/runtime.py b/src/basilisp/lang/runtime.py index f8a323c5..09fb979e 100644 --- a/src/basilisp/lang/runtime.py +++ b/src/basilisp/lang/runtime.py @@ -1876,7 +1876,8 @@ def resolve_alias(s: sym.Symbol, ns: Optional[Namespace] = None) -> sym.Symbol: def resolve_var(s: sym.Symbol, ns: Optional[Namespace] = None) -> Optional[Var]: """Resolve the aliased symbol to a Var from the specified namespace, or the current namespace if none is specified.""" - return Var.find(resolve_alias(s, ns)) + ns_qualified_sym = resolve_alias(s, ns) + return Var.find(resolve_alias(s, ns)) if ns_qualified_sym.ns else None ####################### diff --git a/tests/basilisp/test_core_fns.lpy b/tests/basilisp/test_core_fns.lpy index fa989906..3bb91df6 100644 --- a/tests/basilisp/test_core_fns.lpy +++ b/tests/basilisp/test_core_fns.lpy @@ -1363,6 +1363,21 @@ ;; a valid symbol in that namespace (is (= (resolve 'basilisp.shell/sh) (requiring-resolve 'basilisp.shell/sh)))) +(deftest ns-resolve-test + (is (= #'basilisp.core/apply (ns-resolve *ns* 'apply))) + (is (nil? (ns-resolve *ns* 'xyz))) + + (is (= #'basilisp.set/union (ns-resolve *ns* 'basilisp.set/union))) + (is (= #'basilisp.set/union (ns-resolve *ns* 'set/union))) + (is (nil? (ns-resolve *ns* 'basilisp.set/xyz))) + (is (nil? (ns-resolve *ns* 'set/xyz))) + + (is (= #'basilisp.test/is (ns-resolve *ns* 'is))) + (is (nil? (ns-resolve *ns* '*test-section*))) + (is (= #'basilisp.test/*test-section* (ns-resolve (the-ns 'basilisp.test) '*test-section*))) + + (is (nil? (ns-resolve *ns* 'if)))) + (deftest intern-test (let [ns-sym (gensym "intern-test-ns") ns0 (create-ns ns-sym)]