diff --git a/src/main/cljs/cljs/analyzer/passes.cljc b/src/main/cljs/cljs/analyzer/passes.cljc index 5d1a3a9cf..422504493 100644 --- a/src/main/cljs/cljs/analyzer/passes.cljc +++ b/src/main/cljs/cljs/analyzer/passes.cljc @@ -28,5 +28,5 @@ (let [child (get ast child-k)] (if (vector? child) (into [] (map #(walk % passes opts)) child) - (walk child passes))))) + (walk child passes opts))))) (some-> ast (apply-passes passes opts)) (:children ast)))) diff --git a/src/main/clojure/cljs/analyzer.cljc b/src/main/clojure/cljs/analyzer.cljc index f1d01cbc2..bfe05dcdf 100644 --- a/src/main/clojure/cljs/analyzer.cljc +++ b/src/main/clojure/cljs/analyzer.cljc @@ -2219,7 +2219,8 @@ :init fexpr :variadic? (:variadic? fexpr) :max-fixed-arity (:max-fixed-arity fexpr) - :method-params (map :params (:methods fexpr)))] + :method-params (map :params (:methods fexpr)) + :children [:init])] [(assoc-in env [:locals name] be') (conj bes be')])) [meth-env []] bes) @@ -2296,7 +2297,8 @@ :env {:line line :column col} :info {:name name :shadow shadow} - :binding-form? true} + :binding-form? true + :children [:init]} be (if (= :fn (:op init-expr)) ;; TODO: can we simplify - David (merge be diff --git a/src/test/clojure/cljs/analyzer_pass_tests.clj b/src/test/clojure/cljs/analyzer_pass_tests.clj index a9cc90166..984492564 100644 --- a/src/test/clojure/cljs/analyzer_pass_tests.clj +++ b/src/test/clojure/cljs/analyzer_pass_tests.clj @@ -24,7 +24,17 @@ (analyze expr-env)) ast' (passes/walk ast [(fn [_ ast _] (dissoc ast :env))])] (is (not (contains? ast' :env))) - (is (not (some #(contains? % :env) (:args ast'))))))) + (is (not (some #(contains? % :env) (:args ast'))))) + (let [expr-env (assoc (ana/empty-env) :context :expr) + ast (->> `(let [x# 1 + y# (fn [] x#) + z# (fn [] y#)] + 'x) + (analyze expr-env)) + ast' (passes/walk ast [(fn [_ ast _] (dissoc ast :env))])] + (is (not (contains? ast' :env))) + (is (= 3 (count (:bindings ast')))) + (is (not (some #(contains? % :env) (:bindings ast'))))))) (deftest remove-local (testing "and/or remove local pass" @@ -156,11 +166,19 @@ (for [e s :when (and (sequential? e) (every? (fn [x] x) e))] e)) [[]])]))))] - (is (empty? (re-seq #"and_" code)))))) + (is (empty? (re-seq #"and_" code)))) + (let [code (env/with-compiler-env (env/default-compiler-env) + (comp/with-core-cljs {} + (fn [] + (compile-form-seq + '[(or false + (boolean + (for [s (range 1)] + (map (fn [x] x) s))))]))))] + (is (empty? (re-seq #"or_" code)))))) (comment (test/run-tests) (require '[clojure.pprint :refer [pprint]]) - )