summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/typecheck')
-rw-r--r--testsuite/tests/typecheck/should_compile/QualifiedRecordUpdate.hs10
-rw-r--r--testsuite/tests/typecheck/should_compile/QualifiedRecordUpdate_aux.hs6
-rw-r--r--testsuite/tests/typecheck/should_compile/T21443.hs10
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T6
-rw-r--r--testsuite/tests/typecheck/should_fail/T12035.hs2
-rw-r--r--testsuite/tests/typecheck/should_fail/T21444.hs8
-rw-r--r--testsuite/tests/typecheck/should_fail/T21444.stderr6
-rw-r--r--testsuite/tests/typecheck/should_fail/T7989.stderr15
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail114.stderr6
10 files changed, 51 insertions, 19 deletions
diff --git a/testsuite/tests/typecheck/should_compile/QualifiedRecordUpdate.hs b/testsuite/tests/typecheck/should_compile/QualifiedRecordUpdate.hs
new file mode 100644
index 0000000000..3657ab4463
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/QualifiedRecordUpdate.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE DuplicateRecordFields #-}
+
+module QualifiedRecordUpdate where
+
+import QualifiedRecordUpdate_aux ( R(fld1, fld2), S(fld1, fld2) )
+import qualified QualifiedRecordUpdate_aux as B ( R(fld1, fld2), S(fld1) )
+
+-- Unambiguous record update: the only record datatype in the B namespace
+-- which contains field fld2 is R.
+f r = r { B.fld1 = 3, B.fld2 = False }
diff --git a/testsuite/tests/typecheck/should_compile/QualifiedRecordUpdate_aux.hs b/testsuite/tests/typecheck/should_compile/QualifiedRecordUpdate_aux.hs
new file mode 100644
index 0000000000..c03abe277c
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/QualifiedRecordUpdate_aux.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE DuplicateRecordFields #-}
+
+module QualifiedRecordUpdate_aux where
+
+data R = R { fld1 :: Int, fld2 :: Bool }
+data S = S { fld1 :: Int, fld2 :: Bool, fld3 :: Char }
diff --git a/testsuite/tests/typecheck/should_compile/T21443.hs b/testsuite/tests/typecheck/should_compile/T21443.hs
new file mode 100644
index 0000000000..7dbd451c09
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T21443.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE DuplicateRecordFields #-}
+
+module T21443 where
+
+data R = MkR1 { foo :: Int }
+ | MkR2 { bar :: Int }
+
+data S = MkS { foo :: Int, bar :: Int }
+
+blah x = x { foo = 5, bar = 6 }
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index 327dd93675..4c200961f4 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -865,4 +865,8 @@ test('T22985a', normal, compile, ['-O'])
test('T22985b', normal, compile, [''])
test('T23018', normal, compile, [''])
test('T21909', normal, compile, [''])
-test('T21909b', normal, compile, ['']) \ No newline at end of file
+test('T21909b', normal, compile, [''])
+test('T21443', normal, compile, [''])
+test('QualifiedRecordUpdate',
+ [ extra_files(['QualifiedRecordUpdate_aux.hs']) ]
+ , multimod_compile, ['QualifiedRecordUpdate', '-v0'])
diff --git a/testsuite/tests/typecheck/should_fail/T12035.hs b/testsuite/tests/typecheck/should_fail/T12035.hs
index 87e20ff07c..cd12eee917 100644
--- a/testsuite/tests/typecheck/should_fail/T12035.hs
+++ b/testsuite/tests/typecheck/should_fail/T12035.hs
@@ -1,7 +1,7 @@
module T12035 where
import T12035a
type T = Bool
-y = f True
+--y = f True
-- This should error that 'type T = Int' doesn't match 'data T',
-- NOT that f expects argument of type T but got Bool.
diff --git a/testsuite/tests/typecheck/should_fail/T21444.hs b/testsuite/tests/typecheck/should_fail/T21444.hs
new file mode 100644
index 0000000000..28f2010dbd
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T21444.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE DuplicateRecordFields #-}
+
+module T21444 where
+
+data S = MkS { foo, bar, baz :: Int }
+data T = MkT { foo, bar, baz :: Int }
+
+blah x = x { foo = 1, bar = 2, baz = 3 }
diff --git a/testsuite/tests/typecheck/should_fail/T21444.stderr b/testsuite/tests/typecheck/should_fail/T21444.stderr
new file mode 100644
index 0000000000..cd4795c969
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T21444.stderr
@@ -0,0 +1,6 @@
+
+T21444.hs:8:10: error: [GHC-99339]
+ • Ambiguous record update with fields ‘foo’, ‘bar’ and ‘baz’
+ These fields appear in both datatypes ‘S’ and ‘T’
+ • In the expression: x {foo = 1, bar = 2, baz = 3}
+ In an equation for ‘blah’: blah x = x {foo = 1, bar = 2, baz = 3}
diff --git a/testsuite/tests/typecheck/should_fail/T7989.stderr b/testsuite/tests/typecheck/should_fail/T7989.stderr
index 7413b06648..f5271b2167 100644
--- a/testsuite/tests/typecheck/should_fail/T7989.stderr
+++ b/testsuite/tests/typecheck/should_fail/T7989.stderr
@@ -1,15 +1,4 @@
T7989.hs:6:7: error: [GHC-14392]
- • No constructor has all these fields: ‘a0’, ‘b0’
- • In the expression: x {a0 = 3, a1 = 2, b0 = 4, b1 = 5}
- In an equation for ‘f’: f x = x {a0 = 3, a1 = 2, b0 = 4, b1 = 5}
-
-T7989.hs:9:7: error: [GHC-14392]
- • No constructor has all these fields: ‘x’, ‘y’, ‘z’
- • In the expression: a {x = 0, y = 0, z = 0, v = 0}
- In an equation for ‘g’: g a = a {x = 0, y = 0, z = 0, v = 0}
-
-T7989.hs:11:7: error: [GHC-14392]
- • No constructor has all these fields: ‘x’, ‘a0’
- • In the expression: a {x = 0, a0 = 0}
- In an equation for ‘h’: h a = a {x = 0, a0 = 0}
+ Invalid record update.
+ No constructor in scope has all of the following fields: ‘a0’, ‘b0’
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index 209f292737..2afc480451 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -675,3 +675,4 @@ test('T19627', normal, compile_fail, [''])
test('PatSynExistential', normal, compile_fail, [''])
test('PatSynArity', normal, compile_fail, [''])
test('PatSynUnboundVar', normal, compile_fail, [''])
+test('T21444', normal, compile_fail, [''])
diff --git a/testsuite/tests/typecheck/should_fail/tcfail114.stderr b/testsuite/tests/typecheck/should_fail/tcfail114.stderr
index 7516ebb712..b751b31cd0 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail114.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail114.stderr
@@ -1,5 +1,3 @@
-tcfail114.hs:11:20: error: [GHC-47535]
- • ‘foo’ is not a record selector
- • In the expression: undefined {foo = ()}
- In an equation for ‘test’: test = undefined {foo = ()}
+tcfail114.hs:11:20: error: [GHC-22385]
+ Not in scope: record field ‘foo’