Ticket #5566 (closed bug: fixed)

Opened 19 months ago

Last modified 19 months ago

instance decls via TH: dropped methods and stack overflows

Reported by: FSalad Owned by:
Priority: normal Milestone:
Component: Template Haskell Version: 7.2.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Difficulty:
Test Case: ghci/scripts/T5566 Blocked By:
Blocking: Related Tickets:

Description

{-# LANGUAGE TemplateHaskell #-}

class C a where
    c :: a

$([d| instance C Int where c = 0 |] )

data D = D

$([d| instance C D where c = D |] )

$([d| instance Show D where show _ = "D" |] )

Loading this into GHCI:

/tmp/Foo.hs:6:3:
    Warning: No explicit method nor default method for `c'
    In the instance declaration for `C Int'

/tmp/Foo.hs:10:3:
    Warning: No explicit method nor default method for `c'
    In the instance declaration for `C D'
Ok, modules loaded: Main.
ghci> c :: Int
*** Exception: /tmp/Foo.hs:6:3-35: No instance nor default method for class operation Main.c

ghci> c :: D
*** Exception: stack overflow
ghci> show D
"*** Exception: stack overflow
ghci> 

I also tried putting C and/or D into separate modules, to no effect.

Change History

Changed 19 months ago by FSalad

  • failure changed from None/Unknown to Incorrect result at runtime

Changed 19 months ago by simonpj

  • status changed from new to closed
  • testcase set to ghci/scripts/T5566
  • resolution set to fixed

Happily this is OK in HEAD; I fixed a related bug recently. I'll add a regression test though.

Simon

Note: See TracTickets for help on using tickets.