Opened 8 years ago

Closed 8 years ago

#5700 closed bug (fixed)

TH: InlinePs inside InstanceD are handled inconsistently

Reported by: mikhail.vorozhtsov Owned by:
Priority: normal Milestone: 7.4.1
Component: Template Haskell Version: 7.3
Keywords: Cc: pho@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: th/T5700
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


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:

    `Base.inlinable' is not a (visible) method of class `Base.C'

or, with 7.2.1:

    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).

Change History (5)

comment:1 Changed 8 years ago by PHO

Cc: pho@… added

comment:2 Changed 8 years ago by simonpj@…

commit cfcddaae2382ddb7f6d6d71fd15501709defd3d7

Author: Simon Peyton Jones <>
Date:   Fri Dec 23 17:27:24 2011 +0000

    Make RnEnv.lookupBindGroupOcc work on Orig RdrNames
    Such names can come from Template Haskell; see Trac #5700
    Easily fixed, happily.
    I also renamed lookupSubBndr to lookupSubBndrOcc, which is
    more descriptive.

 compiler/rename/RnEnv.lhs |   20 +++++++++++++-------
 compiler/rename/RnPat.lhs |    2 +-
 2 files changed, 14 insertions(+), 8 deletions(-)

comment:3 Changed 8 years ago by simonpj

difficulty: Unknown
Status: newmerge
Test Case: th/T5700


comment:4 Changed 8 years ago by igloo

Milestone: 7.4.1

comment:5 Changed 8 years ago by igloo

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.