aboutsummaryrefslogtreecommitdiff
path: root/src/lux/analyser/module.clj
diff options
context:
space:
mode:
authorEduardo Julian2016-05-21 20:43:20 -0400
committerEduardo Julian2016-05-21 20:43:20 -0400
commitaa4722d0c459a59ac896ef1b30ff0e141281d41c (patch)
tree0aa53a864d532d76ad3fec2adfeea40b719a7a8d /src/lux/analyser/module.clj
parent55442e41b5889692e2bbacc0f943bd3382e6e11e (diff)
- Merged _lux_alias into _lux_import.
Diffstat (limited to '')
-rw-r--r--src/lux/analyser/module.clj31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/lux/analyser/module.clj b/src/lux/analyser/module.clj
index 3ee9d28d4..4124503bd 100644
--- a/src/lux/analyser/module.clj
+++ b/src/lux/analyser/module.clj
@@ -137,19 +137,24 @@
(defn alias [module alias reference]
(fn [state]
- (if-let [real-name (->> state (&/get$ &/$modules) (&/|get module) (&/get$ $module-aliases) (&/|get alias))]
- ((&/fail-with-loc (str "[Analyser Error] Can't re-use alias \"" alias "\" @ " module))
- state)
- (return* (->> state
- (&/update$ &/$modules
- (fn [ms]
- (&/|update module
- #(&/update$ $module-aliases
- (fn [aliases]
- (&/|put alias reference aliases))
- %)
- ms))))
- nil))))
+ (let [_module_ (->> state (&/get$ &/$modules) (&/|get module))]
+ (if (&/|member? module (->> _module_ (&/get$ $imports)))
+ ((&/fail-with-loc (str "[Analyser Error] Can't create alias that is the same as a module nameL " (pr-str alias) " for " reference))
+ state)
+ (if-let [real-name (->> _module_ (&/get$ $module-aliases) (&/|get alias))]
+ ((&/fail-with-loc (str "[Analyser Error] Can't re-use alias \"" alias "\" @ " module))
+ state)
+ (return* (->> state
+ (&/update$ &/$modules
+ (fn [ms]
+ (&/|update module
+ #(&/update$ $module-aliases
+ (fn [aliases]
+ (&/|put alias reference aliases))
+ %)
+ ms))))
+ nil))))
+ ))
(defn find-def [module name]
(|do [current-module &/get-module-name]