RnIfaces.lhs:931: Non-exhaustive patterns in case

1999-12-14 Thread Ilya Beylin

A very cryptic error message, probably referring to the source code of ghc itself.
It was caused by an empty *.hi for an imported module which happened to be in the 
working directory.
Side remark: if ghc still has run-time errors, why doesn't it decorate them
to make obvously different from the compile errors?
May sound silly, but my first thought was "Cool! ghc warns about incomplete
cases", and then it took me a while to realise that there is no RnIfaces.lhs
anywhere in my filesystem :)

Regards,
Ilya Beylin

The verbose output follows:
---
The Glorious Glasgow Haskell Compilation System, version 4.04, patchlevel 1

Effective command line: -v -c

Ineffective C pre-processor:
echo '{-# LINE 1 "Typechecking.hs" -}'  /tmp/ghc15352.cpp  cat 
Typechecking.hs  /tmp/ghc15352.cpp

real0.0
user0.0
sys 0.0
ghc:compile:Output file Typechecking.o doesn't exist
ghc:compile:Interface file Typechecking.hi doesn't exist
ghc:recompile:Input file Typechecking.hs newer than Typechecking.o

Haskell compiler:
/usr/pd/ghc-4.04/lib/ghc-4.04/hsc /tmp/ghc15352.cpp  
-fignore-interface-pragmas -fomit-interface-pragmas -fsimplify [ -finline-phase2 
-fmax-simplifier-iterations4 ]   -fwarn-overlapping-patterns -fwarn-missing-methods 
-fwarn-duplicate-exports 
 -fhi-version=404 -static -himap=.%.hi:/usr/pd/ghc-4.04/lib/ghc-4.04/imports/std%.hi   
 -v -hifile=/tmp/ghc15352.hi -C=/tmp/ghc15352.hc -F=/tmp/ghc15352_stb.c 
-FH=/tmp/ghc15352_stb.h +RTS -H600 -K100
Glasgow Haskell Compiler, version 4.04, for Haskell 98, compiled by GHC version 4.04

RnIfaces.lhs:931: Non-exhaustive patterns in case



real1.4
user1.1
sys 0.2
deleting... /tmp/ghc15352.cpp /tmp/ghc15352.hi /tmp/ghc15352.hc /tmp/ghc15352_stb.c 
/tmp/ghc15352_stb.h

rm -f /tmp/ghc15352*



infix constructor in a pattern

1999-12-14 Thread Ilya Beylin

The following code is accepted by hugs and hbc, but produces an error in ghc-4.04-1

-
module Bug where
infix 5 |- 
infix 9 :=

data Equal = Char := Int

(|-) :: Int - Equal - Bool
0 |-  x:=y  = 1 |- x:=y
2 |- (x:=y) = 0 |- x:=y
_ |-  _ = False  
-
Bug.hs:8:
`|-' is not a data constructor
In the pattern: 0 |- x := y

Compilation had errors
-
As one can guess,  0 |-  x:=y  is parsed
correctly as  0 |- (x:=y) when on left hand side,
but not on the right hand side.




RE: infix constructor in a pattern

1999-12-14 Thread Simon Marlow

 The following code is accepted by hugs and hbc, but produces 
 an error in ghc-4.04-1
 
 -
 module Bug where
 infix 5 |- 
 infix 9 :=
 
 data Equal = Char := Int
 
 (|-) :: Int - Equal - Bool
 0 |-  x:=y  = 1 |- x:=y
 2 |- (x:=y) = 0 |- x:=y
 _ |-  _ = False  
 -
 Bug.hs:8:
 `|-' is not a data constructor
 In the pattern: 0 |- x := y
 
 Compilation had errors
 -
 As one can guess,  0 |-  x:=y  is parsed
 correctly as  0 |- (x:=y) when on left hand side,
 but not on the right hand side.

Actually the other way around: it's ok on the right, but not on the left.
This is indeed a bug in GHC, but I don't think we'll fix it, at least not in
the near future.

The reason is that to correctly parse these left-hand-sides means knowing
all the fixity info, which can't be known until the whole file has been
parsed and all the interface files have been read.  This means deferring
some things which we currently do during parsing (like grouping the
equations by name) until much later.  Incedentally, there are several other
fixity-related examples that GHC gets wrong (and Hugs, HBC and NHC for that
matter).

Workaround: use explicit parentheses on the left hand side.  Thanks for the
report.

Cheers,
Simon