File tree Expand file tree Collapse file tree
main/clojure/clojure/tools/analyzer/passes
test/clojure/clojure/tools/analyzer Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11Changelog
22========================================
3+ * Unreleased
4+ * TANAL-134: Remove : init from : def 's : children when absent
35* Release 1.0.0 on 18 Feb 2020
46 * Fixed docstrings
57* Release 0.7.0 on 10 Dec 2018
Original file line number Diff line number Diff line change 7373 (if (= new-meta (:form meta))
7474 ast
7575 (assoc ast :meta (replace-meta meta new-meta)))
76- (assoc (dissoc ast :meta ) :children [:init ]))
76+ (let [ast (dissoc ast :meta )]
77+ (if-let [new-children (not-empty (filterv (complement #{:meta }) (:children ast)))]
78+ (assoc ast :children new-children)
79+ (dissoc ast :children ))))
7780 ast)))
7881
7982(defn elide-meta
Original file line number Diff line number Diff line change 183183 (let [i-ast (ast (1 2 ))]
184184 (is (= :invoke (-> i-ast :op )))
185185 (is (= 1 (-> i-ast :fn :form )))
186- (is (= [2 ] (->> i-ast :args (mapv :form ))))))
186+ (is (= [2 ] (->> i-ast :args (mapv :form )))))
187+
188+ (let [def-ast (ast (def a ))]
189+ (is (= :def (-> def-ast :op )))
190+ (is (empty? (-> def-ast :children )))
191+ (is (nil? (:init def-ast ))))
192+
193+ (let [def-ast (ast (def a nil ))]
194+ (is (= :def (-> def-ast :op )))
195+ (is (= [:init ] (:children def-ast )))
196+ (is (= :const (-> def-ast :init :op ))))
197+
198+ (let [def-ast (ast (def a " doc" nil ))]
199+ (is (= :def (-> def-ast :op )))
200+ (is (= [:meta :init ] (:children def-ast )))
201+ (is (= " doc" (-> def-ast :doc )))
202+ (is (= :const (-> def-ast :init :op )))))
You can’t perform that action at this time.
0 commit comments