mirror of
https://github.com/anoma/juvix.git
synced 2024-12-14 17:32:00 +03:00
efb7f2abd0
Filepaths within a Loc must now be absolute or an error is thrown when mkLoc is called. This Loc is used when displaying errors. This commit uses imaginary absolute file paths in the Core repl and Asm commands in the cases (parsing a single expression for example). Before this fix, the `core {repl, read, eval}` and `asm` commands would crash if it encountered an error when invoked with a relative path, or in the case of a repl when parsing a single expression.
20 lines
696 B
Haskell
20 lines
696 B
Haskell
module Commands.Dev.Core.Eval where
|
|
|
|
import Commands.Base
|
|
import Commands.Dev.Core.Eval.Options
|
|
import Evaluator
|
|
import Juvix.Compiler.Core.Data.InfoTable qualified as Core
|
|
import Juvix.Compiler.Core.Translation.FromSource qualified as Core
|
|
|
|
runCommand :: forall r. (Members '[Embed IO, App] r) => CoreEvalOptions -> Sem r ()
|
|
runCommand opts = do
|
|
f :: Path Abs File <- someBaseToAbs' b
|
|
s <- embed (readFile (toFilePath f))
|
|
case Core.runParser f Core.emptyInfoTable s of
|
|
Left err -> exitJuvixError (JuvixError err)
|
|
Right (tab, Just node) -> do evalAndPrint opts tab node
|
|
Right (_, Nothing) -> return ()
|
|
where
|
|
b :: SomeBase File
|
|
b = opts ^. coreEvalInputFile . pathPath
|