Ticket #2677 (closed bug: fixed)

Opened 5 years ago

Last modified 4 years ago

Detection of TF instance conflict depends on instance order

Reported by: reinerp Owned by: chak
Priority: normal Milestone: 6.12 branch
Component: Compiler (Type checker) Version: 6.9
Keywords: TF instance conflict Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: T2677 Blocked By:
Blocking: Related Tickets:

Description

With 6.10 RC1, the following code compiles without complaint:

{-# OPTIONS -fglasgow-exts #-}
module OverlapTest where

type family A x
type instance A a = Bool
type instance A Int = Char

even though the overlapping instances "A a" and "A Int" conflict. Reordering the instances to

{-# OPTIONS -fglasgow-exts #-}
module OverlapTest where

type family A x
type instance A Int = Char
type instance A a = Bool

correctly doesn't compile, complaining about conflicting instances.

Change History

Changed 5 years ago by igloo

  • owner set to chak
  • difficulty set to Unknown
  • milestone set to 6.10.1

Thanks for the report.

Manuel, sounds like one for you?

Changed 5 years ago by igloo

  • priority changed from normal to high

Changed 5 years ago by igloo

  • priority changed from high to normal

Type-family-related bugs aren't release critical

Changed 5 years ago by igloo

  • milestone changed from 6.10.1 to 6.10 branch

Changed 4 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

Changed 4 years ago by chak

  • status changed from new to closed
  • resolution set to fixed

Changed 4 years ago by chak

  • testcase set to T2677

Changed 4 years ago by dorchard

  • version changed from 6.9 to 6.10.3
  • os changed from Unknown/Multiple to Linux
  • architecture changed from Unknown/Multiple to x86_64 (amd64)
  • severity changed from normal to critical

Just discovered this bug today but glad to see it has already been picked up. The bug applies to data families too. You can do some pretty whacked out stuff with this bug, like launching missiles ;)

{-# LANGUAGE TypeFamilies #-}

-- MkFoo is a constructor on pure functions thereore "safe" :)

data family Foo a
data instance Foo a = MkFoo (Int -> Int)

unBox :: Foo a -> (Int -> Int)
unBox (MkFoo x) = x

-- Nasty person adds this code in a module

launchMissiles :: IO ()
launchMissiles = print ("Launching missiles...")

data instance Foo Int = MakeLauncher (IO())
launch = (unBox (MakeLauncher launchMissiles)) 42

launch segfaults, but about 1 in 3 times (depending on the memory layout) the missiles are launched!

Changed 4 years ago by dorchard

  • version changed from 6.10.3 to 6.9
  • os changed from Linux to Unknown/Multiple
  • architecture changed from x86_64 (amd64) to Unknown/Multiple
  • severity changed from critical to normal
Note: See TracTickets for help on using tickets.