[GHC] #11535: Derived instance of Read/Show causes runtime exception for infix Unicode value constructors
GHC
ghc-devs at haskell.org
Thu Feb 4 03:46:20 UTC 2016
#11535: Derived instance of Read/Show causes runtime exception for infix Unicode
value constructors
-------------------------------------+-------------------------------------
Reporter: nushio | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.3
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets: #1544, #11529
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
When I run the following program `test-show.hs` on ghc 7.10.3:
{{{#!hs
data Y = Д星 String String deriving (Eq, Ord, Show, Read)
data X = String :☆ String deriving (Eq, Ord, Show, Read)
main :: IO ()
main = do
let y = Д星 "" ""
d = 0
print $ map fromEnum $ show y
print $ (y, "") `elem` (readsPrec d (showsPrec d y ""))
print $ (read $ show y :: Y)
let x = "" :☆ ""
d = 0
print $ map fromEnum $ show x
print $ (x, "") `elem` (readsPrec d (showsPrec d x ""))
print $ (read $ show x :: X)
}}}
I got the following results:
{{{
$ stack ghc -- --version
The Glorious Glasgow Haskell Compilation System, version 7.10.3
$ stack runhaskell test-show.hs
[1044,26143,32,34,34,32,34,34]
True
Д星 "" ""
[34,34,32,58,9734,32,34,34]
False
test-show.hs: Prelude.read: no parse
}}}
This behavior does not conform to Section 11.4 of Haskell 2010 Language
Specification:
https://www.haskell.org/onlinereport/haskell2010/haskellch11.html#x18-18600011.4
:
> It should be the case that
> (x,"") is an element of (readsPrec d (showsPrec d x ""))
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11535>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list