Skip to content

GHC produces incorrect coercions in hairy code

Andres Löh has been working with an optimized version of generics-sop, and ran into segfaults. He was able to reduce the test case to the attached (still not tiny) one, and could reduce it no further. He discovered the following utterly bogus definition in -ddump-simpl (with -O):

Main.gshowP_$dAll :: All MyShow GHC.Exts.Any
[GblId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
         WorkFree=False, Expandable=True, Guidance=IF_ARGS [] 20 0}]
Main.gshowP_$dAll
  = ghc-prim-0.5.0.0:GHC.Classes.$p1(%,%)
      @ (All MyShow GHC.Exts.Any)
      @ (All (All MyShow) GHC.Exts.Any)
      (ghc-prim-0.5.0.0:GHC.Classes.C:(%%)
       `cast` (Sub (Sym (Main.D:R:AllFk_c[][0] <[*]>_N <All MyShow>_N))
               ; Sym (Main.N:All[0] <[*]>_N <All MyShow>_N <'[]>_N)
               ; Sub
                   (Nth:1
                      (Sub
                         (Sym
                            (Main.D:R:AllFkc:[0] <[*]>_N <All MyShow>_N <'[Char]>_N <'[]>_N))
                       ; (AllF
                            <[*]>_N
                            <All MyShow>_N
                            ((':)
                               <[*]>_N
                               (UnsafeCo nominal '[Char] GHC.Exts.Any)
                               (UnsafeCo nominal '[] GHC.Exts.Any))_N)_R
                       ; Sub
                           (Main.D:R:AllFkc:[0]
                              <[*]>_N <All MyShow>_N <GHC.Exts.Any>_N <GHC.Exts.Any>_N)))
               ; Main.N:All[0]
                   <[*]>_N
                   <All MyShow>_N
                   (UnsafeCo nominal GHC.Exts.Any (GHC.Exts.Any : GHC.Exts.Any))
               ; Sub
                   (Main.D:R:AllFkc:[0]
                      <[*]>_N <All MyShow>_N <GHC.Exts.Any>_N <GHC.Exts.Any>_N)
               :: (() :: Constraint :: Constraint)
                  ~R#
                  ((All MyShow GHC.Exts.Any,
                    All (All MyShow) GHC.Exts.Any) :: Constraint)))
Trac metadata
Trac field Value
Version 8.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC kosmikus
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information