|
11 | 11 | :cljs (:refer-clojure :exclude [macroexpand-1 ns-interns ensure js-reserved]))
|
12 | 12 | #?(:cljs (:require-macros
|
13 | 13 | [cljs.analyzer.macros
|
14 |
| - :refer [no-warn wrapping-errors |
| 14 | + :refer [no-warn wrapping-errors with-warning-handlers |
15 | 15 | disallowing-recur allowing-redef disallowing-ns*]]
|
16 | 16 | [cljs.env.macros :refer [ensure]]))
|
17 | 17 | #?(:clj (:require [cljs.util :as util :refer [ns->relpath topo-sort]]
|
|
722 | 722 | (doseq [handler *cljs-warning-handlers*]
|
723 | 723 | (handler warning-type env extra)))
|
724 | 724 |
|
| 725 | +(defn- accumulating-warning-handler [warn-acc] |
| 726 | + (fn [warning-type env extra] |
| 727 | + (when (warning-type *cljs-warnings*) |
| 728 | + (swap! warn-acc conj [warning-type env extra])))) |
| 729 | + |
| 730 | +(defn- replay-accumulated-warnings [warn-acc] |
| 731 | + (run! #(apply warning %) @warn-acc)) |
| 732 | + |
725 | 733 | (defn- error-data
|
726 | 734 | ([env phase]
|
727 | 735 | (error-data env phase nil))
|
|
2323 | 2331 | loop-lets (cond
|
2324 | 2332 | (true? is-loop) *loop-lets*
|
2325 | 2333 | (some? *loop-lets*) (cons {:params bes} *loop-lets*))
|
2326 |
| - expr (analyze-let-body env context exprs recur-frames loop-lets) |
| 2334 | + ;; Accumulate warnings for deferred replay iff there's a possibility of re-analyzing |
| 2335 | + warn-acc (when (and is-loop |
| 2336 | + (not widened-tags)) |
| 2337 | + (atom [])) |
| 2338 | + expr (if warn-acc |
| 2339 | + (with-warning-handlers [(accumulating-warning-handler warn-acc)] |
| 2340 | + (analyze-let-body env context exprs recur-frames loop-lets)) |
| 2341 | + (analyze-let-body env context exprs recur-frames loop-lets)) |
2327 | 2342 | children [:bindings :body]
|
2328 | 2343 | nil->any (fnil identity 'any)]
|
2329 | 2344 | (if (and is-loop
|
2330 | 2345 | (not widened-tags)
|
2331 | 2346 | (not= (mapv nil->any @(:tags recur-frame))
|
2332 | 2347 | (mapv (comp nil->any :tag) bes)))
|
2333 | 2348 | (recur encl-env form is-loop @(:tags recur-frame))
|
2334 |
| - {:op op |
2335 |
| - :env encl-env |
2336 |
| - :bindings bes |
2337 |
| - :body (assoc expr :body? true) |
2338 |
| - :form form |
2339 |
| - :children children}))) |
| 2349 | + (do |
| 2350 | + (when warn-acc |
| 2351 | + (replay-accumulated-warnings warn-acc)) |
| 2352 | + {:op op |
| 2353 | + :env encl-env |
| 2354 | + :bindings bes |
| 2355 | + :body (assoc expr :body? true) |
| 2356 | + :form form |
| 2357 | + :children children})))) |
2340 | 2358 |
|
2341 | 2359 | (defmethod parse 'let*
|
2342 | 2360 | [op encl-env form _ _]
|
|
0 commit comments