#14925 closed bug (fixed)

Non-ASCII type names get garbled when their `TypeRep` is shown

Reported by: leftaroundabout Owned by:
Priority: low Milestone: 8.4.2
Component: libraries/base Version: 8.2.1
Keywords: Typeable TypeRep Unicode ASCII UTF-8 Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case: typecheck/T14925
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D4530
Wiki Page:

Description

Typeable allows easily showing the name of a type by, well, using show on it. However, this does not work right for types with Unicode symbols in their name:

GHCi, version 8.2.1: http://www.haskell.org/ghc/  :? for help
Prelude> :m +Data.Typeable
Prelude Data.Typeable> data W = W
Prelude Data.Typeable> typeOf W
W
Prelude Data.Typeable> data Ω = Ω
Prelude Data.Typeable> typeOf Ω
Ω

This did not yet happen in GHC-7:

GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
Prelude> :m +Data.Typeable
Prelude Data.Typeable> data W = W
Prelude Data.Typeable> typeOf W
W
Prelude Data.Typeable> data Ω = Ω
Prelude Data.Typeable> typeOf Ω
Ω

N.b.:

Prelude> import Data.ByteString.Char8 as BC8
Prelude BC8> BC8.putStrLn $ pack "Ω"
Ω

So, this appears to be a UTF-8 problem – something interprets bytestring-stored type-representation names as a different character encoding.

Change History (5)

comment:1 Changed 18 months ago by bgamari

Test Case: typecheck/T14925

Very interesting.

Test added in Phab:D4512.

comment:2 Changed 18 months ago by Ben Gamari <ben@…>

In 0703c00/ghc:

testsuite: Add test for #14925

Test Plan: Validate

Reviewers: alpmestan

Reviewed By: alpmestan

Subscribers: alpmestan, leftaroundabout, rwbarton, thomie, carter

GHC Trac Issues: #14925

Differential Revision: https://phabricator.haskell.org/D4512

comment:3 Changed 18 months ago by bgamari

Differential Rev(s): Phab:D4530
Milestone: 8.4.2
Status: newpatch

comment:4 Changed 18 months ago by Ben Gamari <ben@…>

In 20ae19fc/ghc:

base: Fix Unicode handling of TyCon's Show instance

Test Plan: `make test TEST=T14925`

Reviewers: hvr, dfeuer

Reviewed By: dfeuer

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14925

Differential Revision: https://phabricator.haskell.org/D4530

comment:5 Changed 18 months ago by bgamari

Resolution: fixed
Status: patchclosed

Merged to ghc-8.4.

Note: See TracTickets for help on using tickets.