change how macroexpansion is done during inline caching so that nested &env are correctly computed. Allows for inline caching to occur nested inside an inline caching expression
This commit is contained in:
parent
799c6578b8
commit
b8bcfd6054
3 changed files with 20 additions and 3 deletions
|
|
@ -7,7 +7,8 @@
|
||||||
:test-paths ["test", "target/test-classes"]
|
:test-paths ["test", "target/test-classes"]
|
||||||
:jar-exclusions [#"\.cljx"]
|
:jar-exclusions [#"\.cljx"]
|
||||||
:auto-clean false
|
:auto-clean false
|
||||||
:dependencies [[org.clojure/tools.macro "0.1.2"]]
|
:dependencies [[org.clojure/tools.macro "0.1.2"]
|
||||||
|
[riddley "0.1.12"]]
|
||||||
:profiles {:provided {:dependencies
|
:profiles {:provided {:dependencies
|
||||||
[[org.clojure/clojure "1.6.0"]
|
[[org.clojure/clojure "1.6.0"]
|
||||||
[org.clojure/clojurescript "0.0-3211"]]}
|
[org.clojure/clojurescript "0.0-3211"]]}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
(ns com.rpl.specter.macros
|
(ns com.rpl.specter.macros
|
||||||
(:require [com.rpl.specter.impl :as i]
|
(:require [com.rpl.specter.impl :as i]
|
||||||
[clojure.walk :as walk]
|
[clojure.tools.macro :as m]
|
||||||
[clojure.tools.macro :as m])
|
[riddley.walk :as walk])
|
||||||
)
|
)
|
||||||
|
|
||||||
(defn gensyms [amt]
|
(defn gensyms [amt]
|
||||||
|
|
@ -398,6 +398,10 @@
|
||||||
(-> &env keys set) ;clj
|
(-> &env keys set) ;clj
|
||||||
)
|
)
|
||||||
used-locals (vec (i/walk-select local-syms vector path))
|
used-locals (vec (i/walk-select local-syms vector path))
|
||||||
|
|
||||||
|
;; note: very important to use riddley's macroexpand-all here, so that
|
||||||
|
;; &env is preserved in any potential nested calls to select (like via
|
||||||
|
;; a view function)
|
||||||
expanded (walk/macroexpand-all (vec path))
|
expanded (walk/macroexpand-all (vec path))
|
||||||
prepared-path (ic-prepare-path local-syms expanded)
|
prepared-path (ic-prepare-path local-syms expanded)
|
||||||
possible-params (vec (ic-possible-params expanded))
|
possible-params (vec (ic-possible-params expanded))
|
||||||
|
|
|
||||||
|
|
@ -957,3 +957,15 @@
|
||||||
)))
|
)))
|
||||||
(s/must-cache-paths! false)
|
(s/must-cache-paths! false)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(deftest nested-inline-caching-test
|
||||||
|
(is (= [[1]]
|
||||||
|
(let [a :b]
|
||||||
|
(select
|
||||||
|
(s/view
|
||||||
|
(fn [v]
|
||||||
|
(select [(s/keypath v) (s/keypath a)]
|
||||||
|
{:a {:b 1}})))
|
||||||
|
:a
|
||||||
|
))))
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue