Commit b3e30449 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Fix parsing of OPTIONS*/LANGUAGE pragmas in haddock mode

When getting options from basicTypes/RdrName.lhs, we were seeing
text like "-- |\n-- ...\n" in the buffer, and lexer then recognises
"-- |\n-- ..." as a complete ITdocCommentNext token, with the end of
the buffer not reached.

Next time round, when we get more input into the buffer, it started
"\n-- * 'Var.Var': see", so the lexer gave us an ITdocSection token.

However, getOptions' only knew about ITdocCommentNext, and so it
stopped at that point, and didn't see the pragmas further down the file.
This caused the build to fail due to -fwarn-tabs not being turned off.

But actually, we don't really want the haddock docs at this point, so
now we just unset Opt_Haddock in getOptionsFromFile.
parent cdbb4720
......@@ -141,8 +141,17 @@ getOptionsFromFile dflags filename
(openBinaryFile filename ReadMode)
(hClose)
(\handle -> do
opts <- fmap getOptions' $ lazyGetToks dflags filename handle
opts <- fmap getOptions' $ lazyGetToks dflags' filename handle
seqList opts $ return opts)
where -- We don't need to get haddock doc tokens when we're just
-- getting the options from pragmas, and lazily lexing them
-- correctly is a little tricky: If there is "\n" or "\n-"
-- left at the end of a buffer then the haddock doc may
-- continue past the end of the buffer, despite the fact that
-- we already have an apparently-complete token.
-- We therefore just turn Opt_Haddock off when doing the lazy
-- lex.
dflags' = dopt_unset dflags Opt_Haddock
blockSize :: Int
-- blockSize = 17 -- for testing :-)
......@@ -237,9 +246,6 @@ getOptions' toks
parseToks (open:xs)
| ITlanguage_prag <- getToken open
= parseLanguage xs
parseToks (x:xs)
| ITdocCommentNext _ <- getToken x
= parseToks xs
parseToks _ = []
parseLanguage (L loc (ITconid fs):rest)
= checkExtension (L loc fs) :
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment