From 6f9e28be65fdb38e460a7952393ddb7d497a016f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 19 Feb 2016 17:06:21 -0400 Subject: - The analyser disallows importing a module more than once. --- src/lux/analyser/module.clj | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') 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))" -- cgit v1.2.3