Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,247
    • Issues 4,247
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 393
    • Merge Requests 393
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #5700

Closed
Open
Opened Dec 14, 2011 by mikhail.vorozhtsov@trac-mikhail.vorozhtsov

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
Assignee
Assign to
7.4.1
Milestone
7.4.1
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#5700