Skip to content

Commit

Permalink
fix: better report for unresolved symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
armed committed Jun 15, 2022
1 parent aae2037 commit 426a360
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/k16/gx/beta/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,20 @@
;; it in reversed order
:deps-from :gx/start}}})

#?(:clj
(defn quiet-requiring-resolve
[sym]
(try
(requiring-resolve sym)
(catch Throwable _ nil))))

(defn resolve-symbol
[sym]
(when (symbol? sym)
#?(:cljs (impl/namespace-symbol sym)
:clj (some-> sym
(impl/namespace-symbol)
(requiring-resolve)
(quiet-requiring-resolve)
(var-get)))))

(defn ref
Expand Down
2 changes: 1 addition & 1 deletion src/k16/gx/beta/impl.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
(string/split #"\."))]
(loop [p path
obj goog.global]
(if (seq p)
(if (and (seq p) obj)
(recur (rest p) (aget obj (first p)))
obj)))))

Expand Down
10 changes: 10 additions & 0 deletions test/k16/gx/beta/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,13 @@
(testing "should check for circular deps-from"
(is (= "circular :gx/start -> :gx/stop -> :gx/start"
(first (gx/validate-context context)))))))

(deftest unserolvable-symbol-test
(let [graph {:a 'foo.bar/baz}
norm (gx/normalize {:graph graph})]
(is (= {:message "Unable to resolve symbol",
:error-type :normalize-node,
:node-key :a,
:node-contents 'foo.bar/baz,
:internal-data {:form-def 'foo.bar/baz, :token 'foo.bar/baz}}
(first (:failures norm))))))

1 comment on commit 426a360

@vercel
Copy link

@vercel vercel bot commented on 426a360 Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

gx – ./

gx-kepler16.vercel.app
gx-git-master-kepler16.vercel.app
gx.kepler16.com

Please sign in to comment.