Opened 3 years ago

Closed 3 years ago

#7512 closed bug (worksforme)

GHC crashes with multiple => in instance

Reported by: jvictor Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.6.1
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Compile-time crash Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

GHC will crash (rather than a syntax error) if you write

import Data.Array.Unboxed

newtype Vector r = Vector (UArray Int r)

instance (IArray UArray r) => (Num r) => Num (Vector r) where
  (Vector v1) + (Vector v2) = Vector $ listArray (0,0) []

This is unfortunately the smallest program I found that crashes the compiler; removing the definition of (+) yields a syntax error as expected.

Change History (1)

comment:1 Changed 3 years ago by simonpj

  • difficulty set to Unknown
  • Resolution set to worksforme
  • Status changed from new to closed

Really? With 7.6.1 I get

bash$ c:/fp/ghc-7.6.1/bin/ghc -c T7512.hs

T7512.hs:7:10:
    Malformed instance: IArray UArray r => Num r => Num (Vector r)

GHC 7.4.1 indeed crashes with

bash-3.1$ c:/fp/ghc-7.4.1/bin/ghc -c T7512.hs
ghc.exe: panic! (the 'impossible' happened)
  (GHC version 7.4.1 for i386-unknown-mingw32):
	compiler\rename\RnSource.lhs:429:14-81: Irrefutable pattern failed for pattern Data.Maybe.Just (inst_tyvars,
                                                        _,
                                                        SrcLoc.L _ cls,
                                                        _)

So I'll close this as already fixed. Re-open if you disagree.

Simon

Note: See TracTickets for help on using tickets.