-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Fix info lookups from namespaces that don't yet exist #123
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, the idea seems sound. Probably trying to require
things would be excessively obstrusive.
Maybe worth adding some test coverage.
src/orchard/info.clj
Outdated
(some-> (find-ns unqualified-sym) (m/ns-meta))) | ||
;; Lookups in files whose namespaces don't exist yet should still be able | ||
;; to resolve built-ins and fully-qualified syms | ||
(recur (assoc opts :ns 'clojure.core))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor, but the large distance between the if
and this branch makes it a bit hard to track the control flow.
By using an if-not
instead one gets these "degenerate cases" out of one's way, similarly to https://wiki.c2.com/?GuardClause
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. I've addressed this one. I'll still be adding a test and changelog etc.
666599d
to
10aee3d
Compare
Currently when doing a `var-info` from a file before evaluating the `ns` form always fails. The namespace object does not yet exist, and so none of the var resolution strategies work. However fully-qualified vars, namespace names, or built-ins (clojure.core functions) could all be resolved, and it's frustrating that they aren't. This adds a check to see if `(find-ns ns)` returns anything. If not then we are initiating the lookup from a namespace that has not yet been defined, in which case none of the lookup strategies will proceed, so we continue with doing the lookup as if it had been initiated from `clojure.core`.
10aee3d
to
99875ac
Compare
Added a test, appended the CHANGELOG, and swapped the if branches around as suggested by @vemv . I think from my side this is good to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍻
Nice improvement. Thanks! |
Currently when doing a
var-info
from a file before evaluating thens
formalways fails. The namespace object does not yet exist, and so none of the var
resolution strategies work.
However fully-qualified vars, namespace names, or built-ins (clojure.core
functions) could all be resolved, and it's frustrating that they aren't.
This adds a check to see if
(find-ns ns)
returns anything. If not then we areinitiating the lookup from a namespace that has not yet been defined, in which
case none of the lookup strategies will proceed, so we continue with doing the
lookup as if it had been initiated from
clojure.core
.Before submitting a PR make sure the following things have been done:
Thanks!