Skip to content

Commit c70828b

Browse files
Bronsastuarthalloway
authored andcommitted
CLJ-1187 Support retrieval of metadata from quoted empty literals
Signed-off-by: Stuart Halloway <stu@cognitect.com>
1 parent cbb3fdf commit c70828b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/jvm/clojure/lang/Compiler.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,9 @@ else if(v == Boolean.FALSE)
20222022
return NumberExpr.parse((Number)v);
20232023
else if(v instanceof String)
20242024
return new StringExpr((String) v);
2025-
else if(v instanceof IPersistentCollection && ((IPersistentCollection) v).count() == 0)
2025+
else if(v instanceof IPersistentCollection
2026+
&& (((IPersistentCollection) v).count() == 0)
2027+
&& (!(v instanceof IObj) || ((IObj) v).meta() == null))
20262028
return new EmptyExpr(v);
20272029
else
20282030
return new ConstantExpr(v);

test/clojure/test_clojure/metadata.clj

+7
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@
5151
(def ^{:a 1} foo 0)
5252
#'foo)]
5353
(is (= 1 (-> v meta :a)))))
54+
(testing "const vars preserve metadata"
55+
(let [[v1 v2] (eval-in-temp-ns
56+
(def ^:const foo ^:foo [])
57+
(def ^:const bar ^:foo [:bar])
58+
[(meta foo) (meta bar)])]
59+
(is (= {:foo true} v1))
60+
(is (= {:foo true} v2))))
5461
#_(testing "subsequent declare doesn't overwrite metadata"
5562
(let [v (eval-in-temp-ns
5663
(def ^{:b 2} bar 0)

0 commit comments

Comments
 (0)