Opened 23 months ago

Closed 18 months ago

Last modified 18 months ago

#6161 closed bug (fixed)

Program with missing instance accepted by compiler, program <<loops>>

Reported by: wlguest Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.4.1
Keywords: loop Cc: chak
Operating System: Linux Architecture: x86
Type of failure: GHC accepts invalid program Difficulty: Unknown
Test Case: typecheck/should_fail/T6161 Blocked By:
Blocking: Related Tickets:

Description

The following program is accepted by the compiler even though (Fam Float) has no Super instance which is needed for Duper. testProg <<loops>> when run.

Even with the Super (Fam Float) instance added, testProg continues to <<loop>> unless the Duper (Fam a) constraint on Foo a is replaced by a Super (Fam a) constraint.

The problem seems to be an instance of #5751, but I'm not really sure.

{-# LANGUAGE TypeFamilies, FlexibleContexts, FlexibleInstances #-}

data family Fam  a

data instance Fam Float = FamFloat Float

class Super a where
  testSup :: a -> Float

class Super a => Duper a where
  testDup :: a -> Float

--class ( Super (Fam a) ) => Foo a where
class Duper (Fam a) => Foo a where
  testFoo :: Fam a -> Float

instance Foo a => Duper (Fam a) where
  testDup x = testFoo x + testSup x

--instance Super (Fam Float) where
--  testSup (FamFloat x) = x

instance Foo Float where
  testFoo (FamFloat _) = 5.0

testProg :: Float
testProg = testDup (FamFloat 3.0)

Change History (3)

comment:1 Changed 23 months ago by simonpj

  • Cc chak added
  • Difficulty set to Unknown

I think it's very likely to be the same as #5751. I have fixed #5751, but am waiting for Manuel to do the corresponding work to the vectoriser before committing. The fix is on branch silent-sc-args.

So this will certainy be fixed for 7.6. Is it a show stopper for you?

Simon

comment:2 Changed 18 months ago by igloo

  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to T6161

We now get a type error:

T6161.hs:29:12:
    No instance for (Super (Fam Float)) arising from a use of `testDup'
    In the expression: testDup (FamFloat 3.0)
    In an equation for `testProg': testProg = testDup (FamFloat 3.0)

comment:3 Changed 18 months ago by simonpj

  • Test Case changed from T6161 to typecheck/should_fail/T6161

Yes, fixed by the silent-superclass patch.

Note: See TracTickets for help on using tickets.