Fix file loading from REPL

This commit is contained in:
Scott Richmond 2022-06-19 13:34:16 -04:00
parent f8322412b7
commit 5653912f0e
2 changed files with 5 additions and 3 deletions

View File

@ -336,11 +336,13 @@
(defn- interpret-import [ast ctx] (defn- interpret-import [ast ctx]
(let [path (:path ast) (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) (if (contains? @ctx name)
(throw (ex-info (str "Name " name " is alrady bound") {:ast ast})) (throw (ex-info (str "Name " name " is alrady bound") {:ast ast}))
(let [source (try (let [source (try
(loader/load-import path (ludus-resolve :file ctx)) (loader/load-import path from)
(catch Exception e (catch Exception e
(if (::loader/error (ex-data e)) (if (::loader/error (ex-data e))
(throw (ex-info (ex-message e) {:ast ast})) (throw (ex-info (ex-message e) {:ast ast}))

View File

@ -12,5 +12,5 @@
([file from] ([file from]
(load-import (load-import
(fs/path (fs/path
(fs/parent (fs/canonicalize from)) (if (= from :cwd) (fs/cwd) (fs/parent (fs/canonicalize from)))
(fs/path file))))) (fs/path file)))))