Opened 6 years ago

Closed 6 years ago

#3382 closed bug (fixed)

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

Reported by: batterseapower Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.10.4
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Test Case: deSugar/should_run/T3382
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


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


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):

Change History (1)

comment:1 Changed 6 years ago by simonpj

  • difficulty set to Unknown
  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to deSugar/should_run/T3382

Ah yes, excellent point. Fixed by

Mon Jul 20 07:12:26 GMT Daylight Time 2009  [email protected]
  * Fix Trac #3382: desugaring of NPats
  Max spotted that the short-cut rules for desugaring NPats (where
  we compare against a literal) were wrong now that we have overloaded



Note: See TracTickets for help on using tickets.