Ticket #5084 (closed feature request: fixed)

Opened 2 years ago

Last modified 2 years ago

Error message with INLINE/SPECIALISE pragma for class method

Reported by: batterseapower Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.0.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC accepts invalid program Difficulty:
Test Case: typecheck/should_fail/T5084 Blocked By:
Blocking: Related Tickets:

Description

The INLINE/SPECIALISE pragmas in a class declaration apply to the *default methods* in that declaration. However, no error is given if such a pragma is given when no corresponding default method exists, as in this example:

class Foo a where
    bar :: a -> a
    {-# INLINE bar #-}

Change History

Changed 2 years ago by batterseapower

  • status changed from new to patch

I've implemented a patch: see the patch-5084 branches of the testsuite and compiler repos.

Changed 2 years ago by simonpj

  • status changed from patch to closed
  • testcase set to typecheck/should_fail/T5084
  • resolution set to fixed

I found a much simpler way to do this, in TcClassDcl. However it's in a bit that Pedro is meddling with, so I have made the change in the ghc-generics branch:

commit 191292aaa7f56f32fc546478f43aa89ac67c95a3
Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Thu Apr 21 14:03:07 2011 +0100

    Fix Trac #5084
    
    Complain about an INLINE pragma in a class decl
    when there's no corresponding default method

 compiler/typecheck/TcClassDcl.lhs |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

Plus I added a test (also on the ghc-generics branch of testsuite.

Simon

Note: See TracTickets for help on using tickets.