Skip to content

Commit 14689d6

Browse files
Fixed issue with ns-resolve throwing error on macros (#720) (#729)
Hi, could you please consider patch to fix an issue with with `ns-resolve` erroring out on macros. It addresses #720. (part of breaking the individual bugfixes from #723) Thanks --------- Co-authored-by: ikappaki <[email protected]> Co-authored-by: Chris Rink <[email protected]>
1 parent 77e2f29 commit 14689d6

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
* Fix issue with `intern` failing when used (#725).
1717
* Fix issue with `ns` not being available after `in-ns` on the REPL (#718).
1818
* Fixed issue with import modules aliasing using ns eval (#719).
19+
* Fix issue with `ns-resolve` throwing an error on macros (#720).
1920

2021
## [v0.1.0a2]
2122
### Added

src/basilisp/lang/runtime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,8 @@ def resolve_alias(s: sym.Symbol, ns: Optional[Namespace] = None) -> sym.Symbol:
18761876
def resolve_var(s: sym.Symbol, ns: Optional[Namespace] = None) -> Optional[Var]:
18771877
"""Resolve the aliased symbol to a Var from the specified namespace, or the
18781878
current namespace if none is specified."""
1879-
return Var.find(resolve_alias(s, ns))
1879+
ns_qualified_sym = resolve_alias(s, ns)
1880+
return Var.find(resolve_alias(s, ns)) if ns_qualified_sym.ns else None
18801881

18811882

18821883
#######################

tests/basilisp/test_core_fns.lpy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,21 @@
13631363
;; a valid symbol in that namespace
13641364
(is (= (resolve 'basilisp.shell/sh) (requiring-resolve 'basilisp.shell/sh))))
13651365

1366+
(deftest ns-resolve-test
1367+
(is (= #'basilisp.core/apply (ns-resolve *ns* 'apply)))
1368+
(is (nil? (ns-resolve *ns* 'xyz)))
1369+
1370+
(is (= #'basilisp.set/union (ns-resolve *ns* 'basilisp.set/union)))
1371+
(is (= #'basilisp.set/union (ns-resolve *ns* 'set/union)))
1372+
(is (nil? (ns-resolve *ns* 'basilisp.set/xyz)))
1373+
(is (nil? (ns-resolve *ns* 'set/xyz)))
1374+
1375+
(is (= #'basilisp.test/is (ns-resolve *ns* 'is)))
1376+
(is (nil? (ns-resolve *ns* '*test-section*)))
1377+
(is (= #'basilisp.test/*test-section* (ns-resolve (the-ns 'basilisp.test) '*test-section*)))
1378+
1379+
(is (nil? (ns-resolve *ns* 'if))))
1380+
13661381
(deftest intern-test
13671382
(let [ns-sym (gensym "intern-test-ns")
13681383
ns0 (create-ns ns-sym)]

0 commit comments

Comments
 (0)