referred namespace is shadowed by argument name in whitespace mode
Description
Environment
cljs 1934
Attachments
Activity
Confirmed to work on my machine and the squeaky-clean server I set up for testing. Thanks guys!
Looks good. George can you confirm this patch works for you? Thanks!
closure/build benchmarks through a REPL, as per David Nolen's request. edit: I'm compiling the src/cljs folder.
Before Patch:
cljs.closure> (dotimes [_ 10] (time (build "/repos/clojurescript/src/cljs" {:optimizations :none} true)))
"Elapsed time: 3821.425 msecs"
"Elapsed time: 3261.022 msecs"
"Elapsed time: 2977.293 msecs"
"Elapsed time: 3062.12 msecs"
"Elapsed time: 2964.948 msecs"
"Elapsed time: 3025.59 msecs"
"Elapsed time: 2893.04 msecs"
"Elapsed time: 2946.842 msecs"
"Elapsed time: 3108.782 msecs"
"Elapsed time: 2916.127 msecs"
nil
With Patch:
cljs.closure> (dotimes [_ 10] (time (build "/repos/clojurescript/src/cljs" {:optimizations :none} true)))
"Elapsed time: 5722.203 msecs"
"Elapsed time: 3464.829 msecs"
"Elapsed time: 3160.55 msecs"
"Elapsed time: 3283.244 msecs"
"Elapsed time: 3015.998 msecs"
"Elapsed time: 3023.166 msecs"
"Elapsed time: 2991.538 msecs"
"Elapsed time: 2844.978 msecs"
"Elapsed time: 3101.24 msecs"
"Elapsed time: 2860.506 msecs"
nil
Patch: 20131030
This patch uses the analyzer's existing namespaces atom to resolve namespace shadowing conflicts. The compiler's ns-first-segments atom has been removed.
I think this will fix the issue when all files are included and the ns forms are valid. However, the toy example I used where I deleted the bar.cljs file will still be incorrect. Are there any reasons why we would wish to fix that case? It should already throw a warning letting you know your ns form is requiring something it can't find.
Details
Details
Assignee
Reporter
Priority

Under whitespace mode compilation, the argument named "bar" shadows the namespace "bar" in the compiled JS. Interestingly, this problem only occurs consistently when you compile clean; incremental compilation sometimes fixes it.
See attached project for example.
(ns bar) (defn barFunction [x] (+ x 1)) (ns foo (:require [bar :refer [barFunction]])) (defn ^:export fooFunction [bar] (barFunction bar))