pattern matching overlap

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Mon Dec 18 07:02:01 EST 2000


> The program shown below elicits a complaint about pattern overlap for
> doMem1.  I don't expect any complaint.

> doMem1 (NUMOP ADD e1         (CONST i)) = 1
> doMem1 (NUMOP ADD (LREF lab) (CONST i)) = 4
> doMem1 (NUMOP SUB e1         (CONST i)) = 3
> doMem1 (NUMOP SUB (LREF lab) (CONST i)) = 6

I have reformatted your code slightly to make the error more obvious.
For both the ADD and SUB cases, the pattern variable e1 will always
match, and the constructor pattern (LREF lab) will never match because
the former match has already been successful.

An excellent bug-catch from ghc there I think!

Regards,
    Malcolm




More information about the Glasgow-haskell-bugs mailing list