Skip to content

Panic in tidyNPat when using N+k patterns with overloaded strings

Spotted this while reading the source code to tidyNPat. It looked dubious to me, and indeed it is:

{-# OPTIONS_GHC -XOverloadedStrings #-}
module Main where

import Data.String

instance IsString Int where
        fromString x = 1337

f :: Int -> String
f "hello" = "correct"
f _       = "false"

main = do
        print $ f 1337
        print $ f 1338

Result:

mbolingbroke@mb566 ~/Programming/Checkouts
$ ghc --make Boog.hs
[1 of 1] Compiling Main             ( Boog.hs, Boog.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 6.10.3 for i386-apple-darwin):
	tidyNPat
Trac metadata
Trac field Value
Version 6.10.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information