summaryrefslogtreecommitdiff
path: root/testsuite/tests/overloadedrecflds
diff options
context:
space:
mode:
authorAdam Gundry <adam@well-typed.com>2020-04-27 23:22:59 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-05-08 15:29:41 -0400
commit7a763cff78d2d4b23d05554e68138678cb4ba627 (patch)
tree16f7aabfff8879bc7cb027971f5d15fefddb1fce /testsuite/tests/overloadedrecflds
parent926d2aab83dc6068cba76f71a19b040eddc6dee9 (diff)
downloadhaskell-7a763cff78d2d4b23d05554e68138678cb4ba627.tar.gz
Reject all duplicate declarations involving DuplicateRecordFields (fixes #17965)
This fixes a bug that resulted in some programs being accepted that used the same identifier as a field label and another declaration, depending on the order they appeared in the source code.
Diffstat (limited to 'testsuite/tests/overloadedrecflds')
-rw-r--r--testsuite/tests/overloadedrecflds/should_fail/T17965.hs4
-rw-r--r--testsuite/tests/overloadedrecflds/should_fail/T17965.stderr5
-rw-r--r--testsuite/tests/overloadedrecflds/should_fail/all.T1
3 files changed, 10 insertions, 0 deletions
diff --git a/testsuite/tests/overloadedrecflds/should_fail/T17965.hs b/testsuite/tests/overloadedrecflds/should_fail/T17965.hs
new file mode 100644
index 0000000000..b723637f23
--- /dev/null
+++ b/testsuite/tests/overloadedrecflds/should_fail/T17965.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE DuplicateRecordFields #-}
+main = return ()
+newtype Record a = Record { f :: a -> a }
+class C a where f :: a -> a
diff --git a/testsuite/tests/overloadedrecflds/should_fail/T17965.stderr b/testsuite/tests/overloadedrecflds/should_fail/T17965.stderr
new file mode 100644
index 0000000000..446913eda4
--- /dev/null
+++ b/testsuite/tests/overloadedrecflds/should_fail/T17965.stderr
@@ -0,0 +1,5 @@
+
+T17965.hs:4:17: error:
+ Multiple declarations of ‘f’
+ Declared at: T17965.hs:3:29
+ T17965.hs:4:17
diff --git a/testsuite/tests/overloadedrecflds/should_fail/all.T b/testsuite/tests/overloadedrecflds/should_fail/all.T
index 92ff1f0015..bc3c0650d2 100644
--- a/testsuite/tests/overloadedrecflds/should_fail/all.T
+++ b/testsuite/tests/overloadedrecflds/should_fail/all.T
@@ -32,3 +32,4 @@ test('hasfieldfail03', normal, compile_fail, [''])
test('T14953', [extra_files(['T14953_A.hs', 'T14953_B.hs'])],
multimod_compile_fail, ['T14953', ''])
test('DuplicateExports', normal, compile_fail, [''])
+test('T17965', normal, compile_fail, [''])