Opened 8 years ago

Closed 8 years ago

#3412 closed bug (fixed)

the 'impossible' happened (expectJust chooseExternalIds)

Reported by: int-e Owned by: simonmar
Priority: high Milestone: 6.12.1
Component: Compiler Version: 6.11
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


This module fails to compile with ghc head (with optimizations and using a 'perf' build):

module Bug where

import Ix

newtype U = U Int deriving (Eq, Ord)

instance Ix U where
  index (U from, U to) (U idx) = index (from, to) idx

The output is as follows - the underlined part is the identifier that it fails to find. (I added a ++ show id to the message.)

# ghc -c -fforce-recomp -O Bug.hs
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 6.11.20090801 for i386-unknown-linux):
        expectJust chooseExternalIds { GHC.Arr.$windex2 }

Here's a stripped down version of Ix.hs that still exhibits the bug, to make the example more self-contained. It has to be compiled with -O as well:

module Ix2 where

class Ix a where
    index :: (a, a) -> a -> Int

instance Ix Int where
    index (m, n) i
        | m <= i && i <= n = m - i
        | otherwise        = indexError i

{-# NOINLINE indexError #-}
indexError :: a -> b
indexError _ = undefined

Change History (3)

comment:1 Changed 8 years ago by simonmar

difficulty: Unknown
Milestone: 6.12.1
Owner: set to simonmar
Priority: normalhigh

comment:2 Changed 8 years ago by simonmar

Fixed, thanks.

Mon Aug  3 12:28:03 BST 2009  Simon Marlow <>
  * Fix #3412: the worker of an Id might not be a local Id

comment:3 Changed 8 years ago by simonmar

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.