Skip to content

Commit f3886c9

Browse files
committed
CLJS-2109: incorrect syntax-quote symbol resolution (resolve-symbol 'clojure.core) -> 'clojure/core
1 parent 86c79ae commit f3886c9

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/main/clojure/cljs/analyzer.cljc

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,13 @@
842842
(or (js-tag (next pre) tag-type externs' top)
843843
(js-tag (into '[prototype] (next pre)) tag-type (get top tag) top)))))))
844844

845+
(defn dotted-symbol? [sym]
846+
(let [s (str sym)]
847+
#?(:clj (and (.contains s ".")
848+
(not (.contains s "..")))
849+
:cljs (and ^boolean (goog.string/contains s ".")
850+
(not ^boolean (goog.string/contains s ".."))))))
851+
845852
(defn resolve-var
846853
"Resolve a var. Accepts a side-effecting confirm fn for producing
847854
warnings about unresolved vars."
@@ -887,10 +894,7 @@
887894
{:name (symbol (str full-ns) (str (name sym)))
888895
:ns full-ns}))
889896

890-
#?(:clj (and (.contains s ".")
891-
(not (.contains s "..")))
892-
:cljs (and ^boolean (goog.string/contains s ".")
893-
(not ^boolean (goog.string/contains s ".."))))
897+
(dotted-symbol? sym)
894898
(let [idx (.indexOf s ".")
895899
prefix (symbol (subs s 0 idx))
896900
suffix (subs s (inc idx))]
@@ -3318,8 +3322,11 @@
33183322
(instance? File x) (.getAbsolutePath ^File x)
33193323
:default (str x))))
33203324

3321-
(defn resolve-symbol [s]
3322-
(:name (resolve-var (assoc @env/*compiler* :ns (get-namespace *cljs-ns*)) s)))
3325+
(defn resolve-symbol [sym]
3326+
(if (and (not (namespace sym))
3327+
(dotted-symbol? sym))
3328+
sym
3329+
(:name (resolve-var (assoc @env/*compiler* :ns (get-namespace *cljs-ns*)) sym))))
33233330

33243331
#?(:clj
33253332
(defn forms-seq*

src/test/cljs/cljs/core_test.cljs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,10 @@
13351335
(is (= ::not-found (nth (range 2) -2 ::not-found)))
13361336
(is (= ::not-found (nth (range 2 1 0) -2 ::not-found))))
13371337

1338+
(deftest test-cljs-2109
1339+
(testing "Syntax quoted dotted symbol without namespace should resolve to itself"
1340+
(is (= 'clojure.core `clojure.core))))
1341+
13381342
(comment
13391343
;; ObjMap
13401344
;; (let [ks (map (partial str "foo") (range 500))

0 commit comments

Comments
 (0)