Nested SPECIALIZEd functions cause error: "Symbol _BadUTF8_zdf1_closure already defined."
The utf8-string package (in particular, the module Code.Binary.UTF8.Generic) does not compile under ghc-6.9.20080825.
I tried stripping down that module and believe the problem occurs when a SPECIALIZEd function calls another SPECIALIZEd function:
{-# LANGUAGE FlexibleInstances #-}
module BadUTF8 where
import Data.Word
class UTF8Bytes b where
instance UTF8Bytes [Word8] where
{-# SPECIALIZE myfoldr :: (Char -> a -> a) -> a -> [Word8] -> a #-}
myfoldr :: UTF8Bytes b => (Char -> a -> a) -> a -> b -> a
myfoldr _ x _ = x
{-# SPECIALIZE toString :: [Word8] -> String #-}
toString :: UTF8Bytes b => b -> String
toString bs = myfoldr (:) [] bs
Compiling using ghc-6.9.20080825 without -O, or ghc-6.8.3 with or without -O, does not produce an error. However, ghc-6.9.20080825 with optimization produces:
judah-jacobsons-computer:tmp judah$ ~/tmp/ghc-stage/bin/ghc --make -O BadUTF8.hs
[1 of 1] Compiling BadUTF8 ( BadUTF8.hs, BadUTF8.o )
/var/folders/Pm/Pm4yd68oG4qqe-gsgn56W++++TI/-Tmp-/ghc88501_0/ghc88501_0.s:81:0:
FATAL:Symbol _BadUTF8_zdf1_closure already defined.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |