Opened 9 years ago

Closed 9 years ago

Last modified 44 years ago

#383 closed bug (Fixed)

Default methods not in scope for spliced-in instances?

Reported by: sbronson Owned by: simonpj
Priority: normal Milestone:
Component: Template Haskell Version: 6.4
Keywords: Cc:
Operating System: Architecture:
Type of failure: Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

This is a literate haskell bugreport. Save it to
DefaultMethodScopeTH.lhs.

I noticed a problem with instantiating a typeclasse
from Template
Haskell in the same module that defined it. I've bumped
into this
twice close together now, so I figure I really ought to
report it now.

> {-# OPTIONS_GHC -fth #-}
> 
> module DefaultMethodScopeTH where

First, define a typeclass with a default method.

This is probably not a very usefull class, but nobody
wants me to drag
half of the module I'm actually working on into this ;-).

> class Foo a where
>     foo :: a -> a
>     foo = id

Now try to instantiate it from TH with the default method.

> $([d| instance Foo () where |])

Nothing particularly complicated, right?

But when I try to actually build it, I get this:

$ ghc --make DefaultMethodScopeTH.lhs
Chasing modules from: DefaultMethodScopeTH.lhs
Compiling DefaultMethodScopeTH (
DefaultMethodScopeTH.lhs, DefaultMethodScopeTH.o )

DefaultMethodScopeTH.lhs:22:7:
    GHC internal error: `DefaultMethodScopeTH.$dmfoo'
is not in scope
    In the definition of `foo': foo =
DefaultMethodScopeTH.$dmfoo
    In the definition for method `foo'
    In the instance declaration for `Foo ()'

Kind of nasty, eh?

Attachments (1)

DefaultMethodScopeTH.2.lhs (1.2 KB) - added by sbronson 9 years ago.

Download all attachments as: .zip

Change History (3)

comment:1 Changed 9 years ago by sbronson

Logged In: YES 
user_id=237753

Ugg, this looks horrible. That'll teach me to write bug
reports in Emacs, I guess... the autogenerated email looks
very slightly better, but not much. I'm attaching the original.

Changed 9 years ago by sbronson

comment:2 Changed 9 years ago by simonpj

  • Status changed from assigned to closed
Logged In: YES 
user_id=50165

Good bug report, thanks.

Now fixed, and the fix will be in 6.4.1
Note: See TracTickets for help on using tickets.