quotes pretty-printer not working as comments specify
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
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.2.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |