Skip to content

Commit

Permalink
Fixed issue with ns-resolve throwing error on macros (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikappaki committed Dec 14, 2023
1 parent 8a42054 commit 6134270
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Fix issue with `with` failing with a traceback error when an exception is thrown (#714).
* Fix issue with `sort-*` family of funtions returning an error on an empty seq (#716).
* Fix issue with `intern` failing when used (#725).
* Fix issue with `ns-resolve` throwing an error on macros (#720).

## [v0.1.0a2]
### Added
Expand Down
5 changes: 4 additions & 1 deletion src/basilisp/lang/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,10 @@ 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)
var = Var.find(resolve_alias(s, ns)) if ns_qualified_sym.ns else None
return var



#######################
Expand Down
15 changes: 15 additions & 0 deletions tests/basilisp/test_core_fns.lpy
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 6134270

Please sign in to comment.