[commit: ghc] wip/orf-reboot: Extra tests for odd corner cases (094c9e1)

git at git.haskell.org git at git.haskell.org
Tue Jul 7 15:19:54 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/orf-reboot
Link       : http://ghc.haskell.org/trac/ghc/changeset/094c9e1ca01c88675c987380097a962700ce4358/ghc

>---------------------------------------------------------------

commit 094c9e1ca01c88675c987380097a962700ce4358
Author: Adam Gundry <adam at well-typed.com>
Date:   Tue Jul 7 16:13:00 2015 +0100

    Extra tests for odd corner cases


>---------------------------------------------------------------

094c9e1ca01c88675c987380097a962700ce4358
 testsuite/tests/overloadedrecflds/should_fail/all.T           |  2 ++
 .../overloadedrecflds/should_fail/overloadedrecfldsfail08.hs  | 11 +++++++++++
 .../should_fail/overloadedrecfldsfail08.stderr                |  5 +++++
 .../overloadedrecflds/should_fail/overloadedrecfldsfail09.hs  | 11 +++++++++++
 .../should_fail/overloadedrecfldsfail09.stderr                |  4 ++++
 5 files changed, 33 insertions(+)

diff --git a/testsuite/tests/overloadedrecflds/should_fail/all.T b/testsuite/tests/overloadedrecflds/should_fail/all.T
index a8b9308..1447985 100644
--- a/testsuite/tests/overloadedrecflds/should_fail/all.T
+++ b/testsuite/tests/overloadedrecflds/should_fail/all.T
@@ -9,3 +9,5 @@ test('overloadedrecfldsfail06',
      extra_clean(['OverloadedRecFldsFail06_A.hi', 'OverloadedRecFldsFail06_A.o']),
      multimod_compile_fail, ['overloadedrecfldsfail06', ''])
 test('overloadedrecfldsfail07', normal, compile_fail, [''])
+test('overloadedrecfldsfail08', normal, compile_fail, [''])
+test('overloadedrecfldsfail09', normal, compile_fail, [''])
diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail08.hs b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail08.hs
new file mode 100644
index 0000000..e55a6c1
--- /dev/null
+++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail08.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE AllowDuplicateRecordFields, TypeFamilies #-}
+
+data family F a
+data instance F Int  = MkFInt  { x :: Int }
+data instance F Bool = MkFBool { y :: Bool }
+
+-- No data type has both these fields, but they belong to the same
+-- lexical parent (F).  This used to confuse AllowDuplicateRecordFields.
+foo e = e { x = 3, y = True }
+
+main = return ()
diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail08.stderr b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail08.stderr
new file mode 100644
index 0000000..cf37520
--- /dev/null
+++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail08.stderr
@@ -0,0 +1,5 @@
+
+overloadedrecfldsfail08.hs:9:9: error:
+    No constructor has all these fields: ‘x’, ‘y’
+    In the expression: e {x = 3, y = True}
+    In an equation for ‘foo’: foo e = e {x = 3, y = True}
diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail09.hs b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail09.hs
new file mode 100644
index 0000000..d4c0672
--- /dev/null
+++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail09.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE AllowDuplicateRecordFields, TemplateHaskell #-}
+
+data S = MkS { x :: Int }
+data T = MkT { x :: Int }
+
+-- This tests what happens when an ambiguous record update is used in
+-- a splice: since it can't be represented in TH, it should error
+-- cleanly, rather than panicking or silently using one field.
+foo = [e| (MkS 3) { x = 3 } |]
+
+main = return ()
diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail09.stderr b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail09.stderr
new file mode 100644
index 0000000..8d892e3
--- /dev/null
+++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail09.stderr
@@ -0,0 +1,4 @@
+
+overloadedrecfldsfail09.hs:9:11: error:
+    ambiguous record updates not (yet) handled by Template Haskell
+      x = 3



More information about the ghc-commits mailing list