#5398: Multiple declarations of uniquely generated name
---------------------------------+------------------------------------------
    Reporter:  basvandijk        |       Owner:                  
        Type:  bug               |      Status:  new             
    Priority:  normal            |   Component:  Template Haskell
     Version:  7.0.4             |    Keywords:                  
    Testcase:                    |   Blockedby:                  
          Os:  Unknown/Multiple  |    Blocking:                  
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
---------------------------------+------------------------------------------
 I originally [http://code.google.com/p/syb-with-class/issues/detail?id=4
 reported] this problem in the `syb-with-class` bug tracker but I think
 it's a bug in TH possibly related to #5362.

 After increasing the version range of `template-haskell` in `syb-with-
 class` to:

 `template-haskell >= 2.4 && < 2.7`

 the package fails to build on `ghc-7.2.1` with the following error:

 {{{
 $ cabal build --ghc-option=-ddump-splices
 Preprocessing library syb-with-class-0.6.1.2...
 Building syb-with-class-0.6.1.2...
 [4 of 4] Compiling Data.Generics.SYB.WithClass.Instances (
 Data/Generics/SYB/WithClass/Instances.hs,
 dist/build/Data/Generics/SYB/WithClass/Instances.o )
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.
 Loading package array-0.3.0.3 ... linking ... done.
 Loading package containers-0.4.1.0 ... linking ... done.
 Loading package pretty-1.1.0.0 ... linking ... done.
 Loading package template-haskell ... linking ... done.
 Loading package bytestring-0.9.2.0 ... linking ... done.
 Loading package ffi-1.0 ... linking ... done.
 Data/Generics/SYB/WithClass/Instances.hs:1:1: Splicing declarations
     deriveTypeable ['DataType]
   ======>
     Data/Generics/SYB/WithClass/Instances.hs:544:3-29
     instance Typeable DataType where
         { typeOf _
             = mkTyConApp
                 (mkTyCon "Data.Generics.SYB.WithClass.Basics.DataType")
                 ghc-prim:GHC.Types.[] }
 Data/Generics/SYB/WithClass/Instances.hs:1:1: Splicing declarations
     deriveData ['ByteString]
   ======>
     Data/Generics/SYB/WithClass/Instances.hs:726:4-28
     constr_a2Ya :: Constr
     constr_a2Ya = mkConstr dataType_a2Y9 "PS" [] Prefix
     dataType_a2Y9 :: DataType
     dataType_a2Y9 = mkDataType "ByteString" [constr_a2Ya]
     instance (Data ctx (ForeignPtr Word8),
               Data ctx Int,
               Sat (ctx ByteString),
               Sat (ctx (ForeignPtr Word8)),
               Sat (ctx Int)) =>
              Data ctx ByteString where
         { gfoldl _ _f_a2Yb z_a2Yc x_a2Yd
             = case x_a2Yd of {
                 Data.ByteString.Internal.PS arg_a2Ye arg_a2Yf arg_a2Yg
                   -> _f_a2Yb
                        (_f_a2Yb
                           (_f_a2Yb (z_a2Yc Data.ByteString.Internal.PS)
 arg_a2Ye) arg_a2Yf)
                        arg_a2Yg }
           gunfold _ _k_a2Yh z_a2Yi c_a2Yj
             = case constrIndex c_a2Yj of {
                 1 -> _k_a2Yh
                        (_k_a2Yh (_k_a2Yh (z_a2Yi
 Data.ByteString.Internal.PS)))
                 _ -> error "gunfold: fallthrough" }
           toConstr _ x_a2Yk
             = case x_a2Yk of {
                 Data.ByteString.Internal.PS _ _ _ -> constr_a2Ya }
           dataTypeOf _ _ = dataType_a2Y9 }
 Data/Generics/SYB/WithClass/Instances.hs:1:1: Splicing declarations
     deriveData ['L.ByteString]
   ======>
     Data/Generics/SYB/WithClass/Instances.hs:727:4-30
     constr_a30f :: Constr
     constr_a30f = mkConstr dataType_a30e "Empty" [] Prefix
     constr_a30g :: Constr
     constr_a30g = mkConstr dataType_a30e "Chunk" [] Prefix
     dataType_a30e :: DataType
     dataType_a30e = mkDataType "ByteString" [constr_a30f, constr_a30g]
     instance (Data ctx ByteString,
               Data ctx L.ByteString,
               Sat (ctx L.ByteString),
               Sat (ctx ByteString)) =>
              Data ctx L.ByteString where
         { gfoldl _ _f_a30h z_a30i x_a30j
             = case x_a30j of {
                 Data.ByteString.Lazy.Internal.Empty
                   -> z_a30i Data.ByteString.Lazy.Internal.Empty
                 Data.ByteString.Lazy.Internal.Chunk arg_a30k arg_a30l
                   -> _f_a30h
                        (_f_a30h (z_a30i
 Data.ByteString.Lazy.Internal.Chunk) arg_a30k)
                        arg_a30l }
           gunfold _ _k_a30m z_a30n c_a30o
             = case constrIndex c_a30o of {
                 1 -> z_a30n Data.ByteString.Lazy.Internal.Empty
                 2 -> _k_a30m (_k_a30m (z_a30n
 Data.ByteString.Lazy.Internal.Chunk))
                 _ -> error "gunfold: fallthrough" }
           toConstr _ x_a30p
             = case x_a30p of {
                 Data.ByteString.Lazy.Internal.Empty -> constr_a30f
                 Data.ByteString.Lazy.Internal.Chunk _ _ -> constr_a30g }
           dataTypeOf _ _ = dataType_a30e }

 Data/Generics/SYB/WithClass/Instances.hs:727:4:
     Multiple declarations of `dataType'
     Declared at: Data/Generics/SYB/WithClass/Instances.hs:726:4
                  Data/Generics/SYB/WithClass/Instances.hs:727:4

 Data/Generics/SYB/WithClass/Instances.hs:727:4:
     Multiple declarations of `constr'
     Declared at: Data/Generics/SYB/WithClass/Instances.hs:726:4
                  Data/Generics/SYB/WithClass/Instances.hs:727:4
                  Data/Generics/SYB/WithClass/Instances.hs:727:4
 }}}

 The weird thing is that the generated names `dataType_a2Y9`,
 `dataType_a30e`, `constr_a2Ya` and `constr_a30` are all unique.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5398>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to