Details
-
Type:
Defect
-
Status:
Closed
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: Release 1.2
-
Component/s: None
-
Labels:None
-
Approval:Ok
Description
If you call declare on a var that has already been defined, it wipes out the metadata on that var. While this is possible to avoid in most cases, it makes like difficult for automatic code generators or scanners. In particular, autodoc loses information in some cases because of this if it scans a file that has already been pulled in because of a dependency.
Here's an example. This code:
(defn hello "I like documentation!" [] (println "works"))
(hello)
(println (:doc (meta #'hello)))
(println "I do declare!")
(declare hello)
(hello)
(println (:doc (meta #'hello)))
Prints:
works
I like documentation!
I do declare!
works
nil
The last line should be "I like documentation!" again.
Converted from http://www.assembla.com/spaces/clojure/tickets/330
Attachments:
declare-test.clj - https://www.assembla.com/spaces/clojure/documents/bZn8imvTer36QjeJe5cbCb/download/bZn8imvTer36QjeJe5cbCb
declare-preserve-meta.diff - https://www.assembla.com/spaces/clojure/documents/bwNFCIwMSr34TZeJe5cbCb/download/bwNFCIwMSr34TZeJe5cbCb
0330-def-sans-init-touches-no-meta.patch - https://www.assembla.com/spaces/clojure/documents/dRHbioAFCr34lYeJe5cbLA/download/dRHbioAFCr34lYeJe5cbLA