Opened 7 years ago

Closed 7 years ago

#1323 closed bug (wontfix)

crash when zipping two lists of the same length...

Reported by: matthew@… Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.6
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Difficulty: Unknown
Test Case: Session.hs Blocked By:
Blocking: Related Tickets:

Description (last modified by simonpj)

I've personally not checked this against 6.6.1, but "mauke" on #haskell says the same crash and same line number appears in the crash report.

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.6

$ ghc -v --make Session.hs
Glasgow Haskell Compiler, Version 6.6, for Haskell 98, compiled by GHC version 6.6
Using package config file: /usr/lib/ghc-6.6/package.conf
hiding package hinstaller-2007.4.21 to avoid conflict with later version hinstaller-2007.4.24
wired-in package base mapped to base-2.0
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0
wired-in package template-haskell mapped to template-haskell-2.0
Hsc static flags: -static
*** Chasing dependencies:
Chasing modules from: Session.hs
Stable obj: []
Stable BCO: []
compile: input file Session.hs
Created temporary directory: /tmp/ghc4588_0
*** Checking old interface for main:Main:
[1 of 1] Compiling Main             ( Session.hs, Session.o )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
    Result size = 379
*** Simplify:
*** Deleting temp files:
Deleting: /tmp/ghc4588_0/ghc4588_0.s
Warning: deleting non-existent /tmp/ghc4588_0/ghc4588_0.s
*** Deleting temp dirs:
Deleting: /tmp/ghc4588_0
ghc-6.6: panic! (the 'impossible' happened)
  (GHC version 6.6 for x86_64-unknown-linux):
        Pattern match failure in do expression at simplCore/Simplify.lhs:1540:8-21

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Now as the comments in the source say, it works fine if you replace newtype with data, and I am aware that there are differences in what they do, though I can never quite remember the fine details. So it's quite possibly my fault, but an error message other than a GHC crash would be nicer!

Attachments (1)

Session.hs (1.2 KB) - added by matthew@… 7 years ago.
The crashing source code.

Download all attachments as: .zip

Change History (2)

Changed 7 years ago by matthew@…

The crashing source code.

comment:1 Changed 7 years ago by simonpj

  • Description modified (diff)
  • Resolution set to wontfix
  • Status changed from new to closed
  • Test Case set to Session.hs

Good one! What is happening is this. During optimisation, GHC removes impossible alternatives from a case expression. Your program has this:

data List :: * -> * -> * where
             Nil :: List a Zero
             Cons :: (TyNum p) => a -> List a p -> List a (Succ p)

where Succ is a newtype. GHC 6.6 has a split personality about newtypes. During typechecking it regards a newtype T and its representation type as distinct. But during optimisation it regards them as the same. That's WRONG here, because it makes GHC stupidly remove a case alterantive that is not dead.

All this works fine in the HEAD, which regards a newtype and its rep type as distinct throughout (much tidier). So I won't fix 6.6. Meanwhile you'd be better defining your Succ type like this:

  data Succ p

You aren't using it to carry data, and GHC allows you to define data types with no constructors.

I'll add this to the test suite though!

Simon

Note: See TracTickets for help on using tickets.