Some improvements to error traces

This commit is contained in:
John Wiegley 2018-03-30 23:08:59 -07:00
parent d08ca26da0
commit b89b795abe
3 changed files with 13 additions and 12 deletions

View file

@ -185,7 +185,7 @@ eval (NApp fun arg) = fun >>= \case
++ show (newScope args)
clearScopes (pushScope args (forceThunk =<< f))
NVBuiltin _ f -> f =<< buildThunk arg
_ -> throwError "Attempt to call non-function"
x -> throwError $ "Attempt to call non-function: " ++ show (() <$ x)
eval (NAbs params body) = do
-- It is the environment at the definition site, not the call site, that

View file

@ -151,16 +151,17 @@ instance MonadNixEnv (Cyclic IO) where
return $ dir' </> path
x -> error $ "How can the current directory be: " ++ show x
traceM $ "Importing file " ++ path'
eres <- Cyclic $ parseNixFile path'
case eres of
Failure err -> error $ "Parse failed: " ++ show err
Success expr -> do
ref <- buildThunk $ return $
NVLiteralPath $ takeDirectory path'
-- Use this cookie so that when we evaluate the next
-- import, we'll remember which directory its containing
-- file was in.
pushScope (Map.singleton "__cwd" ref) (evalExpr expr)
withStringContext ("While importing file " ++ show path') $ do
eres <- Cyclic $ parseNixFile path'
case eres of
Failure err -> error $ "Parse failed: " ++ show err
Success expr -> do
ref <- buildThunk $ return $
NVLiteralPath $ takeDirectory path'
-- Use this cookie so that when we evaluate the next
-- import, we'll remember which directory its containing
-- file was in.
pushScope (Map.singleton "__cwd" ref) (evalExpr expr)
p -> error $ "Unexpected argument to import: " ++ show (() <$ p)
getEnvVar = forceThunk >=> \case

View file

@ -1 +1 @@
"Hello, world!"
"Hello, world!" 10