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:
Nathan Marz 2016-05-24 17:01:17 -04:00
parent 799c6578b8
commit b8bcfd6054
3 changed files with 20 additions and 3 deletions

View file

@ -7,7 +7,8 @@
:test-paths ["test", "target/test-classes"]
:jar-exclusions [#"\.cljx"]
: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
[[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-3211"]]}

View file

@ -1,7 +1,7 @@
(ns com.rpl.specter.macros
(: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]
@ -398,6 +398,10 @@
(-> &env keys set) ;clj
)
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))
prepared-path (ic-prepare-path local-syms expanded)
possible-params (vec (ic-possible-params expanded))

View file

@ -957,3 +957,15 @@
)))
(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
))))
)