Permalink
Browse files

CLJS-447: Throw exception if multiple namespaces are required with th…

…e same alias

Track aliases in parse 'ns. Throw on duplicate name.
  • Loading branch information...
1 parent 21eab98 commit 7be30517f9204098bd193baa6c8241f8016f2eed @swannodette swannodette committed Dec 22, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/clj/cljs/analyzer.clj
View
5 src/clj/cljs/analyzer.clj
@@ -603,6 +603,7 @@
s))
#{} args)
deps (atom #{})
+ aliases (atom #{})
valid-forms (atom #{:use :use-macros :require :require-macros :import})
error-msg (fn [spec msg] (str msg "; offending spec: " (pr-str spec)))
parse-require-spec (fn parse-require-spec [macros? spec]
@@ -624,6 +625,10 @@
(let [[lib & opts] spec
{alias :as referred :refer :or {alias lib}} (apply hash-map opts)
[rk uk] (if macros? [:require-macros :use-macros] [:require :use])]
+ (when alias
+ (assert (not (contains? @aliases alias))
+ (error-msg spec ":as alias must be unique"))
+ (swap! aliases conj alias))
(assert (or (symbol? alias) (nil? alias))
(error-msg spec ":as must be followed by a symbol in :require / :require-macros"))
(assert (or (and (sequential? referred) (every? symbol? referred))

0 comments on commit 7be3051

Please sign in to comment.