From 162e9baa2158cdbc048b392184b81a35d0a09beb Mon Sep 17 00:00:00 2001 From: simonmar Date: Fri, 23 Mar 2001 17:41:32 +0000 Subject: [PATCH] [project @ 2001-03-23 17:41:32 by simonmar] Add overlapping string pattern test. --- ghc/tests/deSugar/should_compile/ds051.hs | 33 +++++++++++++++++++++++++ ghc/tests/deSugar/should_compile/ds051.stderr | 9 +++++++ 2 files changed, 42 insertions(+) create mode 100644 ghc/tests/deSugar/should_compile/ds051.hs create mode 100644 ghc/tests/deSugar/should_compile/ds051.stderr diff --git a/ghc/tests/deSugar/should_compile/ds051.hs b/ghc/tests/deSugar/should_compile/ds051.hs new file mode 100644 index 0000000..70c51a7 --- /dev/null +++ b/ghc/tests/deSugar/should_compile/ds051.hs @@ -0,0 +1,33 @@ +module ShouldCompile where + +-- !!! test the overlapping patterns detection. + +-- f1 overlaps +f1 "ab" = [] +f1 "ab" = [] +f1 _ = [] + +-- f2 overlaps +f2 "ab" = [] +f2 ('a':'b':[]) = [] +f2 _ = [] + +-- f3 overlaps +f3 ('a':'b':[]) = [] +f3 "ab" = [] +f3 _ = [] + +-- f4 doesn't overlap +f4 "ab" = [] +f4 ('a':'b':'c':[]) = [] +f4 _ = [] + +-- f5 doesn't overlap +f5 ('a':'b':'c':[]) = [] +f5 "ab" = [] +f5 _ = [] + +-- f6 doesn't overlap +f6 "ab" = [] +f6 ('a':[]) = [] +f6 _ = [] diff --git a/ghc/tests/deSugar/should_compile/ds051.stderr b/ghc/tests/deSugar/should_compile/ds051.stderr new file mode 100644 index 0000000..18554db --- /dev/null +++ b/ghc/tests/deSugar/should_compile/ds051.stderr @@ -0,0 +1,9 @@ + +ds051.hs:6: Warning: Pattern match(es) are overlapped in the definition of function `f1': + f1 "ab" = ... + +ds051.hs:11: Warning: Pattern match(es) are overlapped in the definition of function `f2': + f2 ('a' : ('b' : [])) = ... + +ds051.hs:16: Warning: Pattern match(es) are overlapped in the definition of function `f3': + f3 "ab" = ... -- 1.7.10.4