Re: [GHC] #11632: Data.Char repeated readLitChar barfs on output from show "ó1"
GHC
ghc-devs at haskell.org
Tue Jun 28 04:22:46 UTC 2016
#11632: Data.Char repeated readLitChar barfs on output from show "ó1"
-------------------------------------+-------------------------------------
Reporter: inversemot | Owner: kgupta
Type: bug | Status: new
Priority: normal | Milestone:
Component: libraries/base | Version: 7.10.3
Resolution: | Keywords: newcomer
Operating System: Linux | Architecture:
Type of failure: Incorrect result | Unknown/Multiple
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by kgupta):
How do I add a test case for this? There aren't any existing tests as it
is (the only thing that ever even imports `ReadP` is something that is
importing it for the sake of importing it. Is there a separate test suite
for base?
Thanks!
Replying to [comment:5 thomie]:
> inversemot: what should `lexLitChar "\\243\\&1"` return in your opinion:
> 1. unchanged
> `[("\\243","\\&1")]`
> 2. consume the `\\&1`
> `[("\\243","")]`
> 3. consume and include the `\\&1`
> `[("\\243\\&1","")]`
>
> I suppose option 2.
>
> For a newcomer: I think you'll want to either change the function
`lexChar` in the file `libraries/base/Text/Read/Lex.hs`, and/or the
functions `lexLitChar` and `readLitChar` in `libraries/base/GHC/Read.hs`.
>
> * Why not change the function `lexCharE`? Because it is used by the
function `lexLitChar`, which lexes a character surrounded by single
quotes, but `'x\&'` isn't a valid character (maybe it should be? It would
simplify things.). Also note that the function `lexString` handles `\&` by
itself in `lexEmpty`.
>
> Don't forget a [wiki:Building/RunningTests/Adding test] and
[wiki:WorkingConventions/FixingBugs submit] your patch to Phabricator.
>
>
> For reference, the
[https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-200002.6
Haskell 2010 report] has this to say:
>
> > The escape character \& is provided as a “null character” to allow
strings such as "\137\&9" and "\SO\&H" to be constructed (both of length
two). Thus "\&" is equivalent to "" and the character '\&' is disallowed.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11632#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list