TH: InlinePs inside InstanceD are handled inconsistently
Consider the following modules:
module Base where
class C a where
inlinable :: a -> ()
{-# LANGUAGE TemplateHaskell #-}
module TH where
import Language.Haskell.TH
import Base
mkC :: Name -> Q [Dec]
mkC n = return
[InstanceD [] (AppT (ConT ''C) (ConT n))
[ FunD 'inlinable [Clause [WildP] (NormalB (ConE '())) []]
]
]
{-# LANGUAGE TemplateHaskell #-}
module Use where
import TH
data D = D
$(mkC ''D)
which compile just fine with GHC. Lets throw in an InlineP pragma after the FunD:
PragmaD (InlineP 'inlinable (InlineSpec True False Nothing))
Sadly, this results in an error:
Use.hs:9:3:
`Base.inlinable' is not a (visible) method of class `Base.C'
or, with 7.2.1:
Use.hs:9:3:
The INLINE pragma for `Base.inlinable'
lacks an accompanying binding
OK, another try with
PragmaD (InlineP (mkName "inlinable") (InlineSpec True False Nothing))
Still a no-go in 7.3.20111130 (but accepted by 7.2.1):
Use.hs:9:3: `inlinable' is not a (visible) method of class `Base.C'
Finally, I was able to satisfy GHC by importing Base into Use. I think that names in FunD and PragmaD should be treated uniformly (i.e. using 'inlinable works/fails in both cases. I'd prefer it works, without importing Base).
Trac metadata
Trac field | Value |
---|---|
Version | 7.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Template Haskell |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |