[GHC] #11535: Derived instance of Read/Show causes runtime exception for infix Unicode value constructors

GHC ghc-devs at haskell.org
Fri Feb 5 00:20:53 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
      Resolution:                    |             Keywords:  unicode
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #1544, #11529     |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by nushio):

 I actually found out that this issue #11535 have already been fixed as
 result of some other work between 7.10.3 and the latest head. What shall I
 do? I still can submit a patch with test cases for #11535, and I believe
 it is of some help to the ghc.

 {{{
 ~/hub/ghc (fix-11535)$ cat tmp-lex-test.hs
 import GHC.Read
 import Text.ParserCombinators.ReadPrec
 import qualified Text.Read.Lex as L


 data X = String :☆\& String  deriving (Eq, Ord, Show, Read)

 main :: IO ()
 main = do
   print $ readPrec_to_S (expectP $ L.Symbol ":+") 0 ":+"
   print $ readPrec_to_S (expectP $ L.Symbol ":☆") 0 ":☆"
   let x = "" :☆\& ""
       d = 0
   print $ map fromEnum $ show x
   print $ (x, "") `elem` (readsPrec d (showsPrec d x ""))
   print $ (read $ show x :: X)
 ~/hub/ghc (fix-11535)$ ./inplace/bin/runghc tmp-lex-test.hs
 [((),"")]
 [((),"")]
 [34,34,32,58,9734,92,38,32,34,34]
 True
 "" :☆\& ""
 ~/hub/ghc (fix-11535)$ stack runhaskell tmp-lex-test.hs
 Run from outside a project, using implicit global project config
 Using resolver: lts-5.0 from implicit global project's config file:
 /home/nushio/.stack/global-project/stack.yaml
 [((),"")]
 []
 [34,34,32,58,9734,92,38,32,34,34]
 False
 tmp-lex-test.hs: Prelude.read: no parse
 ~/hub/ghc (fix-11535)$ stack ghc -- --version
 Run from outside a project, using implicit global project config
 Using resolver: lts-5.0 from implicit global project's config file:
 /home/nushio/.stack/global-project/stack.yaml
 The Glorious Glasgow Haskell Compilation System, version 7.10.3
 ~/hub/ghc (fix-11535)$ git log | head -n 1
 commit db121b2ec4596b99fed9781ec2d055f29e0d5b20
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11535#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list