#5509: quotes pretty-printer not working as comments specify
---------------------------------+------------------------------------------
Reporter: mgsloan1 | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 7.2.1 | Keywords: prettyprint
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Incorrect warning at
compile-time
---------------------------------+------------------------------------------
I am currently working on a parser for GHC error messages, and would
actually prefer that this remain unfixed, as this would make GHC error
messages slightly harder to parse.
From compiler/utils/Outputable.lhs
{{{
-- quotes encloses something in single quotes...
-- but it omits them if the thing ends in a single quote
-- so that we don't get `foo''. Instead we just have foo'.
quotes d = SDoc $ \sty ->
let pp_d = runSDoc d sty in
case show pp_d of
('\'' : _) -> pp_d
_other -> Pretty.quotes pp_d
}}}
This implementation does not match the comment - the code is checking for
a leading single-quote, not for a trailing one. Therefore the following
code does result in the {{{ `foo'' }}} that the comment specifically
mentions:
{{{
foo' :: (Show a) => a -> IO ()
foo' = print
main = foo' print
}}}
{{{
Test.hs:3:8:
No instance for (Show (a0 -> IO ()))
arising from a use of `foo''
Possible fix: add an instance declaration for (Show (a0 -> IO ()))
In the expression: foo' print
In an equation for `main': main = foo' print
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5509>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs