aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lux/analyser/module.clj28
-rw-r--r--src/lux/compiler.clj3
2 files changed, 17 insertions, 14 deletions
diff --git a/src/lux/analyser/module.clj b/src/lux/analyser/module.clj
index 6eca13b44..8c27fc08d 100644
--- a/src/lux/analyser/module.clj
+++ b/src/lux/analyser/module.clj
@@ -137,19 +137,6 @@
(return* state
(->> state (&/get$ &/$modules) (&/|contains? name)))))
-(defn alias [module alias reference]
- (fn [state]
- (return* (->> state
- (&/update$ &/$modules
- (fn [ms]
- (&/|update module
- #(&/update$ $module-aliases
- (fn [aliases]
- (&/|put alias reference aliases))
- %)
- ms))))
- nil)))
-
(defn dealias [name]
(|do [current-module &/get-module-name]
(fn [state]
@@ -157,6 +144,21 @@
(return* state real-name)
(fail* (str "Unknown alias: " name))))))
+(defn alias [module alias reference]
+ (fn [state]
+ (if-let [real-name (->> state (&/get$ &/$modules) (&/|get module) (&/get$ $module-aliases) (&/|get alias))]
+ (fail* (str "Can't re-use alias \"" alias "\" @ " module))
+ (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]
(fn [state]
diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj
index 694c6bfc4..e16a84b20 100644
--- a/src/lux/compiler.clj
+++ b/src/lux/compiler.clj
@@ -408,7 +408,8 @@
(|do [module-exists? (&a-module/exists? name)]
(if module-exists?
(fail "[Compiler Error] Can't redefine a module!")
- (|do [_ (&a-module/enter-module name)
+ (|do [_ (&&cache/delete name)
+ _ (&a-module/enter-module name)
:let [=class (doto (new ClassWriter ClassWriter/COMPUTE_MAXS)
(.visit Opcodes/V1_6 (+ Opcodes/ACC_PUBLIC Opcodes/ACC_SUPER)
(str (&host/->module-class name) "/_") nil "java/lang/Object" nil)