fix:journal: cyclic include error messages now show the correct line
This commit is contained in:
parent
801a7adaa4
commit
b7c4dc3b53
@ -306,7 +306,7 @@ includedirectivep = do
|
|||||||
Nothing -> paths
|
Nothing -> paths
|
||||||
Just fmt -> map ((show fmt++":")++) paths
|
Just fmt -> map ((show fmt++":")++) paths
|
||||||
-- parse them inline
|
-- parse them inline
|
||||||
forM_ prefixedpaths $ parseIncludedFile pos
|
forM_ prefixedpaths $ parseIncludedFile off pos
|
||||||
|
|
||||||
where
|
where
|
||||||
|
|
||||||
@ -334,19 +334,20 @@ includedirectivep = do
|
|||||||
-- Parse the given included file (and any deeper includes, recursively)
|
-- Parse the given included file (and any deeper includes, recursively)
|
||||||
-- as if it was inlined in the current (parent) file.
|
-- as if it was inlined in the current (parent) file.
|
||||||
-- The position in the parent file is provided for error messages.
|
-- The position in the parent file is provided for error messages.
|
||||||
parseIncludedFile :: MonadIO m => SourcePos -> PrefixedFilePath -> ErroringJournalParser m ()
|
parseIncludedFile :: MonadIO m => Int -> SourcePos -> PrefixedFilePath -> ErroringJournalParser m ()
|
||||||
parseIncludedFile parentpos prefixedpath = do
|
parseIncludedFile off pos prefixedpath = do
|
||||||
let (_mprefix,filepath) = splitReaderPrefix prefixedpath
|
let (_mprefix,filepath) = splitReaderPrefix prefixedpath
|
||||||
|
|
||||||
|
-- Throw an error if a cycle is detected
|
||||||
parentj <- get
|
parentj <- get
|
||||||
let parentfilestack = jincludefilestack parentj
|
let parentfilestack = jincludefilestack parentj
|
||||||
when (filepath `elem` parentfilestack) $
|
when (filepath `elem` parentfilestack) $
|
||||||
Fail.fail ("Cyclic include: " ++ filepath)
|
customFailure $ parseErrorAt off $ "Cyclic include: " ++ filepath
|
||||||
|
|
||||||
childInput <-
|
childInput <-
|
||||||
dbg6Msg ("parseChild: "++takeFileName filepath) $
|
dbg6Msg ("parseChild: "++takeFileName filepath) $
|
||||||
lift $ readFilePortably filepath
|
lift $ readFilePortably filepath
|
||||||
`orRethrowIOError` (show parentpos ++ " reading " ++ filepath)
|
`orRethrowIOError` (show pos ++ " reading " ++ filepath)
|
||||||
let initChildj = newJournalWithParseStateFrom filepath parentj
|
let initChildj = newJournalWithParseStateFrom filepath parentj
|
||||||
|
|
||||||
-- Choose a reader/parser based on the file path prefix or file extension,
|
-- Choose a reader/parser based on the file path prefix or file extension,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user