Skip to content

TH instance declaration quotes broken

Instance declaration quotes and splices are broken in two way. Consider these modules:

module TH where
import Language.Haskell.TH

class C a where
    foo :: a -> Int

bar = [d| instance C Int where foo = id |]

module TH1 where
import Language.Haskell.TH
import TH

$bar

Compiling these and dumping splices gives the following:

TH1.hs:1:1: Splicing declarations
    bar
  ======>
    TH1.hs:6:1-4
    instance C Int where
        { foo_aWZ = id }

TH1.hs:6:1:
    Warning: No explicit method nor default method for `foo'
    In the instance declaration for `C Int'

Note how the foo method has been renamed to foo_aWZ. This is the first bug. The second bug is that there is no sanity check to make sure instance declarations only contain the methods of the class and not some other junk.

Trac metadata
Trac field Value
Version 7.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information