Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue with ns-resolve throwing error on macros (#720) #729

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/basilisp/lang/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


#######################
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
Loading