[commit: haddock] master: Prevent source parser from throwing exception when lexing fails. (311b3cc)

git at git.haskell.org git at git.haskell.org
Wed Jul 8 08:41:04 UTC 2015


Repository : ssh://git@git.haskell.org/haddock

On branch  : master
Link       : http://git.haskell.org/haddock.git/commitdiff/311b3cc529097ef83a8212439dafcabb86534c62

>---------------------------------------------------------------

commit 311b3cc529097ef83a8212439dafcabb86534c62
Author: Łukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date:   Sun Jun 28 22:28:00 2015 +0200

    Prevent source parser from throwing exception when lexing fails.


>---------------------------------------------------------------

311b3cc529097ef83a8212439dafcabb86534c62
 haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
index 6e195db..bab5ba0 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
@@ -63,7 +63,9 @@ chunk str@(c:_)
 chunk str
     | "--" `isPrefixOf` str = chunk' $ spanToNewline str
     | "{-" `isPrefixOf` str = chunk' $ chunkComment 0 str
-    | otherwise = chunk' $ head $ lex str
+    | otherwise = case lex str of
+        (tok:_) -> chunk' tok
+        [] -> [str]
   where
     chunk' (c, rest) = c:(chunk rest)
 



More information about the ghc-commits mailing list