Commit d6c33da8 authored by Jessica Clarke's avatar Jessica Clarke Committed by Ben Gamari
Browse files

RtClosureInspect: Fix inspecting Char# on 64-bit big-endian

Char# is represented with a full machine word, whereas Char's Storable
instance uses an Int32, so we can't just treat it like a single-element
Char array. Instead, read it as an Int and use chr to turn it into a
Char. This fixes Trac #11262.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #11262

Differential Revision:
parent a69fa544
......@@ -57,6 +57,7 @@ import TysWiredIn
import DynFlags
import Outputable as Ppr
import GHC.Arr ( Array(..) )
import GHC.Char
import GHC.Exts
import GHC.IO ( IO(..) )
......@@ -489,7 +490,9 @@ cPprTermBase y =
repPrim :: TyCon -> [Word] -> SDoc
repPrim t = rep where
rep x
| t == charPrimTyCon = text $ show (build x :: Char)
-- Char# uses native machine words, whereas Char's Storable instance uses
-- Int32, so we have to read it as an Int.
| t == charPrimTyCon = text $ show (chr (build x :: Int))
| t == intPrimTyCon = text $ show (build x :: Int)
| t == wordPrimTyCon = text $ show (build x :: Word)
| t == floatPrimTyCon = text $ show (build x :: Float)
......@@ -21,8 +21,7 @@ test('print018', extra_files(['../Test.hs']), ghci_script, ['print018.script'])
test('print019', extra_files(['../Test.hs']), ghci_script, ['print019.script'])
test('print020', extra_files(['../HappyTest.hs']), ghci_script, ['print020.script'])
test('print021', normal, ghci_script, ['print021.script'])
test('print022', when(arch('powerpc64'), expect_broken(11262)),
ghci_script, ['print022.script'])
test('print022', normal, ghci_script, ['print022.script'])
test('print023', extra_files(['../Test.hs']), ghci_script, ['print023.script'])
test('print024', extra_files(['../Test.hs']), ghci_script, ['print024.script'])
test('print025', normal, ghci_script, ['print025.script'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment