Browse files

CLJS-447: Allow each ns alias to be used up to twice

Each alias can now be used up to twice, once for a fn namespace and
once for a macro namespace. This allows the following (which had
worked before 7be3051):

(ns foo.user
  (:require [foo.core :as f])
  (:require-macros [foo.core :as f]))
  • Loading branch information...
Tom Jack authored and swannodette committed Dec 23, 2012
1 parent 7be3051 commit 882597c258e31b4d8ebb3fdb233eaec4f059725b
Showing with 8 additions and 4 deletions.
  1. +8 −4 src/clj/cljs/analyzer.clj
@@ -603,7 +603,7 @@
#{} args)
deps (atom #{})
- aliases (atom #{})
+ aliases (atom {:fns #{} :macros #{}})
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]
@@ -626,9 +626,13 @@
{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))
+ (let [alias-type (if macros? :macros :fns)]
+ (assert (not (contains? (alias-type @aliases)
+ alias))
+ (error-msg spec ":as alias must be unique"))
+ (swap! aliases
+ update-in [alias-type]
+ 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 882597c

Please sign in to comment.