on master help sign in
Catch import errors in the right place
693e3e4Edwin Brady
src/Idris/Chaser.hs+10−7
@@ -70,9 +70,11 @@ getIModTime (LIDR i) = getModificationTime i
70
70
71buildTree :: [FilePath] -> -- already guaranteed built
71buildTree :: [FilePath] -> -- already guaranteed built
72 FilePath -> Idris [ModuleTree]
72 FilePath -> Idris [ModuleTree]
73+buildTree built fp = btree [] fp
73−buildTree built fp = idrisCatch (btree [] fp)
74+-- = idrisCatch (btree [] fp)
74− (\e -> do now <- runIO $ getCurrentTime
75+-- (\e -> do now <- runIO $ getCurrentTime
76+-- iputStrLn (show e)
75− return [MTree (IDR fp) True now []])
77+-- return [MTree (IDR fp) True now []])
76 where
78 where
77 btree done f =
79 btree done f =
78 do i <- getIState
80 do i <- getIState
@@ -81,6 +83,7 @@ buildTree built fp = idrisCatch (btree [] fp)
81 ibcsd <- valIBCSubDir i
83 ibcsd <- valIBCSubDir i
82 ids <- allImportDirs
84 ids <- allImportDirs
83 fp <- runIO $ findImport ids ibcsd file
85 fp <- runIO $ findImport ids ibcsd file
86+ iLOG $ "Found " ++ show fp
84 mt <- runIO $ getIModTime fp
87 mt <- runIO $ getIModTime fp
85 if (file `elem` built)
88 if (file `elem` built)
86 then return [MTree fp False mt []]
89 then return [MTree fp False mt []]
@@ -123,13 +126,13 @@ buildTree built fp = idrisCatch (btree [] fp)
123 else return False
126 else return False
124
127
125 children :: Bool -> FilePath -> [FilePath] -> Idris [ModuleTree]
128 children :: Bool -> FilePath -> [FilePath] -> Idris [ModuleTree]
126− children lit f done = idrisCatch
129+ children lit f done = -- idrisCatch
127− (do exist <- runIO $ doesFileExist f
130+ do exist <- runIO $ doesFileExist f
128 if exist then do
131 if exist then do
129 file_in <- runIO $ readFile f
132 file_in <- runIO $ readFile f
130 file <- if lit then tclift $ unlit f file_in else return file_in
133 file <- if lit then tclift $ unlit f file_in else return file_in
131 (_, modules, _) <- parseImports f file
134 (_, modules, _) <- parseImports f file
132 ms <- mapM (btree done) modules
135 ms <- mapM (btree done) modules
133 return (concat ms)
136 return (concat ms)
134− else return []) -- IBC with no source available
137+ else return [] -- IBC with no source available
135− (\c -> return []) -- error, can't chase modules here
138+-- (\c -> return []) -- error, can't chase modules here
src/Idris/Core/TT.hs+2
@@ -148,6 +148,8 @@ instance Show Err where
148 show (Inaccessible n) = show n ++ " is not an accessible pattern variable"
148 show (Inaccessible n) = show n ++ " is not an accessible pattern variable"
149 show (ProviderError msg) = "Type provider error: " ++ msg
149 show (ProviderError msg) = "Type provider error: " ++ msg
150 show (LoadingFailed fn e) = "Loading " ++ fn ++ " failed: " ++ show e
150 show (LoadingFailed fn e) = "Loading " ++ fn ++ " failed: " ++ show e
151+ show ProgramLineComment = "Program line next to comment"
152+ show (At f e) = show f ++ ":" ++ show e
151 show _ = "Error"
153 show _ = "Error"
152
154
153instance Pretty Err where
155instance Pretty Err where
src/Idris/REPL.hs+47−50
@@ -1038,56 +1038,53 @@ idris opts = do res <- runErrorT $ execStateT (idrisMain opts) idrisInit
1038
1038
1039loadInputs :: Handle -> [FilePath] -> Idris ()
1039loadInputs :: Handle -> [FilePath] -> Idris ()
1040loadInputs h inputs
1040loadInputs h inputs
1041+ = idrisCatch
1041− = do ist <- getIState
1042+ (do ist <- getIState
1042− -- if we're in --check and not outputting anything, don't bother
1043+ -- if we're in --check and not outputting anything, don't bother
1043− -- loading, as it gets really slow if there's lots of modules in
1044+ -- loading, as it gets really slow if there's lots of modules in
1044− -- a package (instead, reload all at the end to check for
1045+ -- a package (instead, reload all at the end to check for
1045− -- consistency only)
1046+ -- consistency only)
1046− opts <- getCmdLine
1047+ opts <- getCmdLine
1047−
1048+
1048− let loadCode = case opt getOutput opts of
1049+ let loadCode = case opt getOutput opts of
1049− [] -> not (NoREPL `elem` opts)
1050+ [] -> not (NoREPL `elem` opts)
1050− _ -> True
1051+ _ -> True
1051−
1052+
1052− -- For each ifile list, check it and build ibcs in the same clean IState
1053+ -- For each ifile list, check it and build ibcs in the same clean IState
1053− -- so that they don't interfere with each other when checking
1054+ -- so that they don't interfere with each other when checking
1054−
1055+
1055− let ninputs = zip [1..] inputs
1056+ let ninputs = zip [1..] inputs
1056− ifiles <- mapM (\(num, input) ->
1057+ ifiles <- mapM (\(num, input) ->
1057− do putIState ist
1058+ do putIState ist
1058− v <- verbose
1059+ v <- verbose
1059−-- when v $ iputStrLn $ "(" ++ show num ++ "/" ++
1060+ -- when v $ iputStrLn $ "(" ++ show num ++ "/" ++
1060−-- show (length inputs) ++
1061+ -- show (length inputs) ++
1061−-- ") " ++ input
1062+ -- ") " ++ input
1062− modTree <- buildTree
1063+ modTree <- buildTree
1063− (map snd (take (num-1) ninputs))
1064+ (map snd (take (num-1) ninputs))
1064− input
1065+ input
1065− let ifiles = getModuleFiles modTree
1066+ let ifiles = getModuleFiles modTree
1066− iLOG ("MODULE TREE : " ++ show modTree)
1067+ iLOG ("MODULE TREE : " ++ show modTree)
1067− iLOG ("RELOAD: " ++ show ifiles)
1068+ iLOG ("RELOAD: " ++ show ifiles)
1068− when (not (all ibc ifiles) || loadCode) $ tryLoad ifiles
1069+ when (not (all ibc ifiles) || loadCode) $ tryLoad ifiles
1069− -- return the files that need rechecking
1070+ -- return the files that need rechecking
1070− return (if (all ibc ifiles) then ifiles else []))
1071+ return (if (all ibc ifiles) then ifiles else []))
1071− ninputs
1072+ ninputs
1072− inew <- getIState
1073+ inew <- getIState
1073− -- to check everything worked consistently (in particular, will catch
1074+ -- to check everything worked consistently (in particular, will catch
1074− -- if the ibc version is out of date) if we weren't loading per
1075+ -- if the ibc version is out of date) if we weren't loading per
1075− -- module
1076+ -- module
1076− case errLine inew of
1077+ case errLine inew of
1077− Nothing ->
1078+ Nothing ->
1078− do putIState ist
1079+ do putIState ist
1079− when (not loadCode) $ tryLoad $ nub (concat ifiles)
1080+ when (not loadCode) $ tryLoad $ nub (concat ifiles)
1080− _ -> return ()
1081+ _ -> return ()
1081− putIState inew
1082+ putIState inew)
1082−-- inew <- getIState
1083−-- case errLine inew of
1083+ (\e -> case e of
1084−-- Nothing ->
1084+ At f e -> do setErrLine (fc_line f)
1085−-- -- Then, load all the ibcs again, if there were no errors.
1085+ iputStrLn (show e)
1086−-- do putIState ist
1086+ _ -> do setErrLine 3 -- FIXME! Propagate it
1087−-- modTree <- mapM (buildTree (map snd ninputs)) inputs
1087+ iputStrLn (show e))
1088−-- let ifiless = map getModuleFiles modTree
1089−-- mapM_ loadFromIFile (concat ifiless)
1090−-- _ -> return ()
1091 where -- load all files, stop if any fail
1088 where -- load all files, stop if any fail
1092 tryLoad :: [IFileType] -> Idris ()
1089 tryLoad :: [IFileType] -> Idris ()
1093 tryLoad [] = return ()
1090 tryLoad [] = return ()
test/test034/run+1−1
@@ -2,7 +2,7 @@
2
2
3HEAD="module Main
3HEAD="module Main
4
4
5−import Data.Float
5+import Data.Floats
6
6
7main : IO ()"
7main : IO ()"
8
8