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:

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])

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

user=> (defn weird-args-1 {:arglists (list ['source '& parser-opts-arg])} [y] (dec y))
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=> (: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
Reference: https://clojure.atlassian.net/browse/TANAL-126 (reported by jafingerhut)