diff --git a/CHANGELOG.md b/CHANGELOG.md index e5382270..bd18070a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## master (unreleased) +* [#135](https://github.com/clojure-emacs/orchard/issues/135): Fix problematic double var lookup in `orchard.xref/fn-refs` + ## 0.7.3 (2021-10-02) ### Changes diff --git a/src/orchard/xref.clj b/src/orchard/xref.clj index c7e6bb05..c11dfb90 100644 --- a/src/orchard/xref.clj +++ b/src/orchard/xref.clj @@ -48,6 +48,5 @@ [var] (let [var (as-var var) all-vars (q/vars {:ns-query {:project? true} :private? true}) - all-vals (map var-get all-vars) - deps-map (zipmap all-vars (map fn-deps all-vals))] + deps-map (zipmap all-vars (map fn-deps all-vars))] (map first (filter (fn [[_k v]] (contains? v var)) deps-map)))) diff --git a/test/orchard/xref_test.clj b/test/orchard/xref_test.clj index 0dd743cc..a7c1c46d 100644 --- a/test/orchard/xref_test.clj +++ b/test/orchard/xref_test.clj @@ -20,6 +20,15 @@ #{#'clojure.core/map #'clojure.core/filter #'clojure.core/even? #'clojure.core/range})))) +;; The mere presence of this var can reproduce a certain issue. See: +;; https://github.com/clojure-emacs/orchard/issues/135#issuecomment-939731698 +(def xxx 'foo/bar) + +;; Like the above, but programmatic, to ensure that we the presence of a .clj file named `foo` +;; won't cause a false negative: +(def yyy (symbol (str (gensym)) + (str (gensym)))) + (deftest fn-refs-test (testing "with a fn value" (is (= (xref/fn-refs dummy-fn) '()))