Skip to content

Commit 4d5b6bb

Browse files
committed
capture avoidance check
1 parent 93bbf75 commit 4d5b6bb

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

test/java_time/dev/gen.clj

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
(:require [clojure.string :as str]
33
[clojure.set :as set]))
44

5+
(def impl-local-sym '+impl+)
6+
57
(defn normalize-argv [argv]
68
{:post [(or (empty? %)
7-
(apply distinct? %))]}
9+
(apply distinct? %))
10+
(not-any? #{impl-local-sym} %)]}
811
(into [] (map-indexed (fn [i arg]
912
(if (symbol? arg)
1013
(do (assert (not (namespace arg)))
@@ -29,13 +32,13 @@
2932
forward-meta (into (sorted-map) (select-keys m [:doc :tag :deprecated]))
3033
forward-meta (cond-> forward-meta
3134
(nil? (:tag forward-meta)) (dissoc :tag))
32-
impl '+impl+]
35+
_ (assert (not= n impl-local-sym))]
3336
(when (:macro m)
3437
(throw (IllegalArgumentException.
3538
(str "Calling import-fn on a macro: " sym))))
36-
(list 'let [impl (list 'delay
37-
(list 'load-java-time)
38-
(list 'deref (list 'resolve (list 'quote sym))))]
39+
(list 'let [impl-local-sym (list 'delay
40+
(list 'load-java-time)
41+
(list 'deref (list 'resolve (list 'quote sym))))]
3942
(list* 'defn n
4043
(concat
4144
(some-> (not-empty forward-meta) list)
@@ -44,8 +47,8 @@
4447
(let [argv (normalize-argv argv)]
4548
(list argv
4649
(if (some #{'&} argv)
47-
(list* 'apply (list 'deref impl) (remove #{'&} argv))
48-
(list* (list 'deref impl) argv)))))
50+
(list* 'apply (list 'deref impl-local-sym) (remove #{'&} argv))
51+
(list* (list 'deref impl-local-sym) argv)))))
4952
arglists)))))))
5053

5154
(defn import-macro [sym]

0 commit comments

Comments
 (0)