diff options
author | Eduardo Julian | 2016-02-19 17:06:21 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-02-19 17:06:21 -0400 |
commit | 6f9e28be65fdb38e460a7952393ddb7d497a016f (patch) | |
tree | 6f352823f84e2eddd133ee2e07e44415de1bfec6 | |
parent | 86f2337ef398f38e76b4763b3941785d63e4caa9 (diff) |
- The analyser disallows importing a module more than once.
-rw-r--r-- | src/lux/analyser/module.clj | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lux/analyser/module.clj b/src/lux/analyser/module.clj index 23696dced..ddec601b1 100644 --- a/src/lux/analyser/module.clj +++ b/src/lux/analyser/module.clj @@ -41,13 +41,15 @@ "(-> Text (Lux Null))" (|do [current-module &/get-module-name] (fn [state] - (return* (&/update$ &/$modules - (fn [ms] - (&/|update current-module - (fn [m] (&/update$ $imports (partial &/$Cons module) m)) - ms)) - state) - nil)))) + (if (&/|member? module (->> state (&/get$ &/$modules) (&/|get current-module) (&/get$ $imports))) + (fail* (str "Can't import module " (pr-str module) " twice @ " current-module)) + (return* (&/update$ &/$modules + (fn [ms] + (&/|update current-module + (fn [m] (&/update$ $imports (partial &/$Cons module) m)) + ms)) + state) + nil))))) (defn set-imports [imports] "(-> (List Text) (Lux Null))" |