diff --git a/src/expand.clj b/src/expand.clj index b4c3cc6..086f7bd 100644 --- a/src/expand.clj +++ b/src/expand.clj @@ -498,11 +498,18 @@ (let [c (atom {})] (clojure.walk/postwalk (fn [x] - (if (and (symbol? x) (str/starts-with? (name x) "scope__")) - (let [syms (swap! c #(if (contains? % x) - % - (assoc % x (symbol (str "s" (count %))))))] - (get syms x)) + (if (instance? Variable x) + (let [[sym scopes] (destructure-variable x) + syms (swap! + c + #(let [r (set/difference scopes (keys %))] + (into % + (map-indexed + (fn [n a] + [a (symbol (str "s" (+ (dec (count r)) n)))]) + r))))] + #_(->Variable sym (set (map #(get syms %) scopes))) + [sym (set (map #(get syms %) scopes))]) x)) datum)))