lib: fail when file to include is in stack of 'include' files

This commit is contained in:
Joseph Weston 2018-08-02 08:38:56 +02:00 committed by Simon Michael
parent 1d91ea43a5
commit 40d70ad10b

View File

@ -216,6 +216,10 @@ includedirectivep = do
else parseErrorAt parserpos $ "No existing files match pattern: " ++ filename
parseChild parentpos filepath = do
parentfilestack <- fmap sourceName . statePos <$> getParserState
when (filepath `elem` parentfilestack)
$ parseErrorAt parentpos ("Cyclic include: " ++ filepath)
childInput <- lift $ readFilePortably filepath
`orRethrowIOError` (show parentpos ++ " reading " ++ filepath)