Skip to content

Rejection of constant functions defined using conditional pattern matching

Hi,

The Haskell program below is rejected, although it is correct. GHC gives the following error message:

HASKELL/tricky.hs:12:1:
    Multiple declarations of `Main.d3'
    Declared at: HASKELL/tricky.hs:10:1
                 HASKELL/tricky.hs:11:1
                 HASKELL/tricky.hs:12:1 

I agree that the definition of d3 is tricky and useless, but it seems to be valid. This example was exctracted from Haskell code automatically produced by an in-house code generator.

data Nat = D0 | Succ Nat
  deriving (Show, Eq, Ord)

d1 :: Nat
d2 :: Nat
d3 :: Nat

d1 = (Succ D0)
d2 | D0 == D0 = D0
d3 | D0 /= D0 = D0
d3 | (Succ D0) == D0 = D0
d3 | (Succ D0) /= D0 = (Succ D0)

main = do
 print d1
 print d2
 print d3 

Best regards Hubert

Trac metadata
Trac field Value
Version 7.10.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Linux
Architecture x86
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information