Welcome! Please see the About page for a little more info on how this works.

0 votes
in tools.analyzer by
The interaction below is an experiment I did because I was trying to
figure out why tools.analyzer.jvm was throwing an exception while
analyzing the function `parse` in data.xml here, in particular its odd
definition of the value for `:arglists` metadata:
https://github.com/clojure/data.xml/blob/master/src/main/clojure/clojure/data/xml.clj#L107

I was using Ubuntu 18.04 Linux, OpenJDK 11, Leiningen 2.8.1, Clojure
1.9.0, in case it makes a difference.


$ git clone https://github.com/clojure/tools.analyzer.jvm
$ cd tools.analyzer.jvm
$ git checkout 205f24504c7cc4d0365b8de096470f406eff7ee8
$ lein repl

;; ... other output elided

user=> (require '[clojure.tools.analyzer.jvm :as j])
nil

user=> (def ^:const parser-opts-arg '{:keys [a b] :or {a true b 5}})
#'user/parser-opts-arg

user=> (defn weird-args-1 {:arglists (list ['source '& parser-opts-arg])} [y] (dec y))
#'user/weird-args-1
user=> (:arglists (meta #'weird-args-1))
([source & {:keys [a b], :or {a true, b 5}}])

user=> (def x (j/analyze+eval '(defn weird-arglists-2 {:arglists (list ['source '& parser-opts-arg])} [x] (inc x))))
#'user/x
user=> (:arglists (meta #'weird-arglists-2))
[(quote source) (quote &) parser-opts-arg]


The final value for the Var's :arglists metadata seems to differ by
one eval.

1 Answer

0 votes
by
Reference: https://clojure.atlassian.net/browse/TANAL-126 (reported by jafingerhut)
...