File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 23842384 (let [init-expr (analyze-let-binding-init env init (cons {:params bes} *loop-lets*))
23852385 line (get-line name env)
23862386 col (get-col name env)
2387- shadow (handle-symbol-local name (get-in env [:locals name]))
2387+ shadow (or (handle-symbol-local name (get-in env [:locals name]))
2388+ (get-in env [:js-globals name]))
23882389 be {:name name
23892390 :line line
23902391 :column col
Original file line number Diff line number Diff line change 11131113 ana/*fn-invoke-direct* (and static-fns fn-invoke-direct)
11141114 *repl-opts* opts]
11151115 (try
1116- (let [env { :context :expr :locals {}}
1116+ (let [env ( assoc ( ana/empty-env ) :context :expr )
11171117 special-fns (merge default-special-fns special-fns)
11181118 is-special-fn? (set (keys special-fns))
11191119 request-prompt (Object. )
Original file line number Diff line number Diff line change 365365 ns-info (env/ensure (comp/emit-source input output " cljs" {}))]
366366 (is (= 'foo.foo (:ns ns-info)))))
367367
368+ (deftest test-3368-global-shadowing
369+ (testing " Let binding which use JS global names should get shadowed"
370+ (let [code (env/with-compiler-env (env/default-compiler-env )
371+ (compile-form-seq
372+ '[(defn foo []
373+ (let [window js/window]
374+ window))]))]
375+ (is (re-find #"window__\$ 1" code)))))
368376
369377; ; CLJS-1225
370378
You can’t perform that action at this time.
0 commit comments