aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html-test/ref/Bug298.html133
-rw-r--r--html-test/src/Bug298.hs22
-rw-r--r--src/Haddock/Parser.hs10
3 files changed, 164 insertions, 1 deletions
diff --git a/html-test/ref/Bug298.html b/html-test/ref/Bug298.html
new file mode 100644
index 00000000..03ed5eeb
--- /dev/null
+++ b/html-test/ref/Bug298.html
@@ -0,0 +1,133 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+ ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+ /><title
+ >Bug298</title
+ ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+ /><script src="haddock-util.js" type="text/javascript"
+ ></script
+ ><script type="text/javascript"
+ >//<![CDATA[
+window.onload = function () {pageLoad();setSynopsis("mini_Bug298.html");};
+//]]>
+</script
+ ></head
+ ><body
+ ><div id="package-header"
+ ><ul class="links" id="page-menu"
+ ><li
+ ><a href=""
+ >Contents</a
+ ></li
+ ><li
+ ><a href=""
+ >Index</a
+ ></li
+ ></ul
+ ><p class="caption empty"
+ >&nbsp;</p
+ ></div
+ ><div id="content"
+ ><div id="module-header"
+ ><table class="info"
+ ><tr
+ ><th
+ >Safe Haskell</th
+ ><td
+ >Safe-Inferred</td
+ ></tr
+ ></table
+ ><p class="caption"
+ >Bug298</p
+ ></div
+ ><div id="synopsis"
+ ><p id="control.syn" class="caption expander" onclick="toggleSection('syn')"
+ >Synopsis</p
+ ><ul id="section.syn" class="hide" onclick="toggleSection('syn')"
+ ><li class="src short"
+ ><a href=""
+ >(&lt;^&gt;)</a
+ > :: (a -&gt; a) -&gt; a -&gt; a</li
+ ><li class="src short"
+ ><a href=""
+ >(&lt;^)</a
+ > :: a -&gt; a -&gt; a</li
+ ><li class="src short"
+ ><a href=""
+ >(^&gt;)</a
+ > :: a -&gt; a -&gt; a</li
+ ><li class="src short"
+ ><a href=""
+ >(&#8902;^)</a
+ > :: a -&gt; a -&gt; a</li
+ ><li class="src short"
+ ><a href=""
+ >f</a
+ > :: ()</li
+ ></ul
+ ></div
+ ><div id="interface"
+ ><h1
+ >Documentation</h1
+ ><div class="top"
+ ><p class="src"
+ ><a name="v:-60--94--62-" class="def"
+ >(&lt;^&gt;)</a
+ > :: (a -&gt; a) -&gt; a -&gt; a</p
+ ></div
+ ><div class="top"
+ ><p class="src"
+ ><a name="v:-60--94-" class="def"
+ >(&lt;^)</a
+ > :: a -&gt; a -&gt; a</p
+ ></div
+ ><div class="top"
+ ><p class="src"
+ ><a name="v:-94--62-" class="def"
+ >(^&gt;)</a
+ > :: a -&gt; a -&gt; a</p
+ ></div
+ ><div class="top"
+ ><p class="src"
+ ><a name="v:-8902--94-" class="def"
+ >(&#8902;^)</a
+ > :: a -&gt; a -&gt; a</p
+ ></div
+ ><div class="top"
+ ><p class="src"
+ ><a name="v:f" class="def"
+ >f</a
+ > :: ()</p
+ ><div class="doc"
+ ><p
+ >Links to <code
+ ><a href=""
+ >&lt;^&gt;</a
+ ></code
+ > and <code
+ ><a href=""
+ >^&gt;</a
+ ></code
+ >, <code
+ ><a href=""
+ >&lt;^</a
+ ></code
+ > and <code
+ ><a href=""
+ >&#8902;^</a
+ ></code
+ >.</p
+ ></div
+ ></div
+ ></div
+ ></div
+ ><div id="footer"
+ ><p
+ >Produced by <a href=""
+ >Haddock</a
+ > version 2.15.0</p
+ ></div
+ ></body
+ ></html
+>
diff --git a/html-test/src/Bug298.hs b/html-test/src/Bug298.hs
new file mode 100644
index 00000000..07d6fa0c
--- /dev/null
+++ b/html-test/src/Bug298.hs
@@ -0,0 +1,22 @@
+-- We introduced a regression in 2.14.x where we don't consider
+-- identifiers with ^ as valid. We test that the regression goes away
+-- here. It's a silly typo in the parser, really. Same with ★ which is a valid
+-- symbol according to the 2010 report.
+module Bug298 where
+
+
+(<^>) :: (a -> a) -> a -> a
+x <^> y = x y
+
+(<^) :: a -> a -> a
+x <^ y = x
+
+(^>) :: a -> a -> a
+x ^> y = y
+
+(⋆^) :: a -> a -> a
+x ⋆^ y = y
+
+-- | Links to '<^>' and '^>', '<^' and '⋆^'.
+f :: ()
+f = ()
diff --git a/src/Haddock/Parser.hs b/src/Haddock/Parser.hs
index bd5cd200..ece9291f 100644
--- a/src/Haddock/Parser.hs
+++ b/src/Haddock/Parser.hs
@@ -419,13 +419,21 @@ autoUrl = mkLink <$> url
-- characters and does no actual validation itself.
parseValid :: Parser String
parseValid = do
- vs <- many' $ satisfy (`elem` "_.!#$%&*+/<=>?@\\|-~:") <|> digit <|> letter_ascii
+ vs' <- many' $ utf8String "⋆" <|> return <$> idChar
+ let vs = concat vs'
c <- peekChar
case c of
Just '`' -> return vs
Just '\'' -> (\x -> vs ++ "'" ++ x) <$> ("'" *> parseValid)
<|> return vs
_ -> fail "outofvalid"
+ where
+ idChar = satisfy (`elem` "_.!#$%&*+/<=>?@\\|-~:^")
+ <|> digit <|> letter_ascii
+
+-- | Parses UTF8 strings from ByteString streams.
+utf8String :: String -> Parser String
+utf8String x = decodeUtf8 <$> string (encodeUtf8 x)
-- | Parses identifiers with help of 'parseValid'. Asks GHC for 'RdrName' from the
-- string it deems valid.