diff --git a/src/ludus/interpreter.clj b/src/ludus/interpreter.clj index 2a21108..573f4f4 100644 --- a/src/ludus/interpreter.clj +++ b/src/ludus/interpreter.clj @@ -336,11 +336,13 @@ (defn- interpret-import [ast ctx] (let [path (:path ast) - name (:name ast)] + name (:name ast) + file (ludus-resolve :file ctx) + from (if (= ::not-found file) :cwd file)] (if (contains? @ctx name) (throw (ex-info (str "Name " name " is alrady bound") {:ast ast})) (let [source (try - (loader/load-import path (ludus-resolve :file ctx)) + (loader/load-import path from) (catch Exception e (if (::loader/error (ex-data e)) (throw (ex-info (ex-message e) {:ast ast})) diff --git a/src/ludus/loader.clj b/src/ludus/loader.clj index 888682f..f8ba0a0 100644 --- a/src/ludus/loader.clj +++ b/src/ludus/loader.clj @@ -12,5 +12,5 @@ ([file from] (load-import (fs/path - (fs/parent (fs/canonicalize from)) + (if (= from :cwd) (fs/cwd) (fs/parent (fs/canonicalize from))) (fs/path file)))))