summaryrefslogtreecommitdiff
path: root/testsuite/tests/rename
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/rename')
-rw-r--r--testsuite/tests/rename/should_compile/T22122.hs18
-rw-r--r--testsuite/tests/rename/should_compile/T22122_aux.hs68
-rw-r--r--testsuite/tests/rename/should_compile/all.T1
-rw-r--r--testsuite/tests/rename/should_fail/T11167_ambig.stderr12
-rw-r--r--testsuite/tests/rename/should_fail/T12681.stderr3
-rw-r--r--testsuite/tests/rename/should_fail/T19843f.stderr10
-rw-r--r--testsuite/tests/rename/should_fail/T19843g.stderr6
-rw-r--r--testsuite/tests/rename/should_fail/T19843h.stderr4
-rw-r--r--testsuite/tests/rename/should_fail/T21605a.stderr5
-rw-r--r--testsuite/tests/rename/should_fail/T21605d.stderr7
-rw-r--r--testsuite/tests/rename/should_fail/T7943.hs2
-rw-r--r--testsuite/tests/rename/should_fail/T7943.stderr7
-rw-r--r--testsuite/tests/rename/should_fail/T9077.stderr2
-rw-r--r--testsuite/tests/rename/should_fail/T9156.stderr6
-rw-r--r--testsuite/tests/rename/should_fail/T9156_DF.hs10
-rw-r--r--testsuite/tests/rename/should_fail/T9156_DF.stderr3
-rw-r--r--testsuite/tests/rename/should_fail/all.T1
-rw-r--r--testsuite/tests/rename/should_fail/rn_dup.hs2
-rw-r--r--testsuite/tests/rename/should_fail/rn_dup.stderr8
-rw-r--r--testsuite/tests/rename/should_fail/rnfail054.stderr6
20 files changed, 135 insertions, 46 deletions
diff --git a/testsuite/tests/rename/should_compile/T22122.hs b/testsuite/tests/rename/should_compile/T22122.hs
new file mode 100644
index 0000000000..25f8377e96
--- /dev/null
+++ b/testsuite/tests/rename/should_compile/T22122.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE DuplicateRecordFields #-}
+{-# LANGUAGE NoFieldSelectors #-}
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE TemplateHaskell #-}
+
+module T22122 where
+
+import T22122_aux ( data_decls, record_upds )
+
+-- This test checks that we can handle record declarations and updates
+-- when the field 'Name's share the same underlying string.
+
+-- data D1 = MkD1 { fld1 :: Char, fld2 :: String }
+-- data D2 = MkD2A { fld1 :: Char } | MkD2B { fld2 :: String }
+$(return data_decls)
+
+-- rec_upd r = r { fld1 = 'c', fld2 = "foo" }
+$(return record_upds)
diff --git a/testsuite/tests/rename/should_compile/T22122_aux.hs b/testsuite/tests/rename/should_compile/T22122_aux.hs
new file mode 100644
index 0000000000..b62aaa5840
--- /dev/null
+++ b/testsuite/tests/rename/should_compile/T22122_aux.hs
@@ -0,0 +1,68 @@
+{-# LANGUAGE DeriveTraversable #-}
+{-# LANGUAGE DerivingStrategies #-}
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE TemplateHaskell #-}
+
+module T22122_aux where
+
+import Language.Haskell.TH.Syntax
+ ( Name, Type(ConT), Lit(CharL, StringL)
+ , Dec(DataD, FunD), Con(RecC), Exp(LitE, VarE, RecUpdE), Pat(VarP)
+ , Clause(Clause), Body(NormalB)
+ , Bang(..), SourceUnpackedness(..), SourceStrictness(..)
+ , newNameIO )
+import System.IO.Unsafe
+ ( unsafePerformIO )
+
+
+data Names a
+ = Names { d1_name, d2_name
+ , mkd1_name, mkd2a_name, mkd2b_name
+ , d1_fld1_name, d1_fld2_name, d2_fld1_name, d2_fld2_name
+ , upd_name, upd_var_name :: a }
+ deriving stock ( Functor, Foldable, Traversable )
+
+string_names :: Names String
+string_names =
+ Names
+ { d1_name = "D1"
+ , d2_name = "D2"
+ , mkd1_name = "MkD1"
+ , mkd2a_name = "MkD2A"
+ , mkd2b_name = "MkD2B"
+ , d1_fld1_name = "fld" -- these are deliberately the same,
+ , d1_fld2_name = "fld" -- to check that we correctly use the exact Names
+ , d2_fld1_name = "fld" -- in a record update, and not simply the
+ , d2_fld2_name = "fld" -- field label strings
+ , upd_name = "upd"
+ , upd_var_name = "r"
+ }
+
+names :: Names Name
+names = unsafePerformIO $ traverse newNameIO string_names
+
+noBang :: Bang
+noBang = Bang NoSourceUnpackedness NoSourceStrictness
+
+-- data D1 = MkD1 { fld1 :: Char, fld2 :: String }
+-- data D2 = MkD2A { fld1 :: Char } | MkD2B { fld2 :: String }
+data_decls :: [ Dec ]
+data_decls = [ d1, d2 ]
+ where
+ Names { .. } = names
+ d1 = DataD [] d1_name [] Nothing [mkd1] []
+ d2 = DataD [] d2_name [] Nothing [mkd2_a, mkd2_b] []
+ mkd1 = RecC mkd1_name [(d1_fld1_name, noBang, ConT ''Char), (d1_fld2_name, noBang, ConT ''String)]
+ mkd2_a = RecC mkd2a_name [(d2_fld1_name, noBang, ConT ''Char)]
+ mkd2_b = RecC mkd2b_name [(d2_fld2_name, noBang, ConT ''String)]
+
+-- upd r = r { fld1 = 'c', fld2 = "foo" }
+record_upds :: [ Dec ]
+record_upds = [ rec_upd ]
+ where
+ Names { .. } = names
+ rec_upd = FunD upd_name [upd_clause]
+ upd_clause = Clause [VarP upd_var_name] (NormalB rec_upd_body) []
+ rec_upd_body = RecUpdE (VarE upd_var_name)
+ [ (d1_fld1_name, LitE (CharL 'c'))
+ , (d1_fld2_name, LitE (StringL "foo")) ]
diff --git a/testsuite/tests/rename/should_compile/all.T b/testsuite/tests/rename/should_compile/all.T
index ba05c88357..55f58fcebc 100644
--- a/testsuite/tests/rename/should_compile/all.T
+++ b/testsuite/tests/rename/should_compile/all.T
@@ -208,3 +208,4 @@ test('GADTSymbolicRecordRecordWildcard', normal, compile, [''])
test('ImportNullaryRecordWildcard', [extra_files(['NullaryRecordWildcard.hs', 'NullaryRecordRecordWildcard.hs'])], multimod_compile, ['ImportNullaryRecordWildcard', '-v0'])
test('GHCINullaryRecordWildcard', combined_output, ghci_script, ['GHCINullaryRecordWildcard.script'])
test('GHCIImplicitImportNullaryRecordWildcard', combined_output, ghci_script, ['GHCIImplicitImportNullaryRecordWildcard.script'])
+test('T22122', [expect_broken(22122), extra_files(['T22122_aux.hs'])], multimod_compile, ['T22122', '-v0'])
diff --git a/testsuite/tests/rename/should_fail/T11167_ambig.stderr b/testsuite/tests/rename/should_fail/T11167_ambig.stderr
index 8c9c6a7848..74c7064414 100644
--- a/testsuite/tests/rename/should_fail/T11167_ambig.stderr
+++ b/testsuite/tests/rename/should_fail/T11167_ambig.stderr
@@ -2,15 +2,15 @@
T11167_ambig.hs:10:13: error:
Ambiguous occurrence ‘runContT’
It could refer to
- either the field ‘runContT’ of record ‘ContT'’,
- defined at T11167_ambig.hs:7:32
- or the field ‘runContT’ of record ‘ContT’,
+ either the field ‘runContT’ of record ‘ContT’,
defined at T11167_ambig.hs:6:30
+ or the field ‘runContT’ of record ‘ContT'’,
+ defined at T11167_ambig.hs:7:32
T11167_ambig.hs:17:9: error:
Ambiguous occurrence ‘runContT’
It could refer to
- either the field ‘runContT’ of record ‘ContT'’,
- defined at T11167_ambig.hs:7:32
- or the field ‘runContT’ of record ‘ContT’,
+ either the field ‘runContT’ of record ‘ContT’,
defined at T11167_ambig.hs:6:30
+ or the field ‘runContT’ of record ‘ContT'’,
+ defined at T11167_ambig.hs:7:32
diff --git a/testsuite/tests/rename/should_fail/T12681.stderr b/testsuite/tests/rename/should_fail/T12681.stderr
index 3a48d80c17..6b57b8517b 100644
--- a/testsuite/tests/rename/should_fail/T12681.stderr
+++ b/testsuite/tests/rename/should_fail/T12681.stderr
@@ -1,4 +1,5 @@
T12681.hs:4:17: error: [GHC-76037]
Not in scope: ‘a’
- Suggested fix: Perhaps use ‘T12681a.a’ (imported from T12681a)
+ Suggested fix:
+ Perhaps use record field of A ‘T12681a.a’ (imported from T12681a)
diff --git a/testsuite/tests/rename/should_fail/T19843f.stderr b/testsuite/tests/rename/should_fail/T19843f.stderr
index c7c4d5dc58..4cf8e47089 100644
--- a/testsuite/tests/rename/should_fail/T19843f.stderr
+++ b/testsuite/tests/rename/should_fail/T19843f.stderr
@@ -1,8 +1,4 @@
-T19843f.hs:8:12: error: [GHC-76037]
- Not in scope: ‘mup’
- Suggested fix: Perhaps use ‘mop’ (line 5)
-
-T19843f.hs:10:10: error: [GHC-76037]
- Not in scope: ‘mup’
- Suggested fix: Perhaps use ‘mop’ (line 5)
+T19843f.hs:8:12: error: [GHC-22385]
+ Not in scope: record field ‘mup’
+ Suggested fix: Perhaps use record field of A ‘mop’ (line 5)
diff --git a/testsuite/tests/rename/should_fail/T19843g.stderr b/testsuite/tests/rename/should_fail/T19843g.stderr
index 78ee13eadf..e6441413be 100644
--- a/testsuite/tests/rename/should_fail/T19843g.stderr
+++ b/testsuite/tests/rename/should_fail/T19843g.stderr
@@ -1,4 +1,4 @@
-T19843g.hs:10:12: error: [GHC-76037]
- Not in scope: ‘mup’
- Suggested fix: Perhaps use ‘mop’ (line 7)
+T19843g.hs:10:12: error: [GHC-22385]
+ Not in scope: record field ‘mup’
+ Suggested fix: Perhaps use record field of A ‘mop’ (line 7)
diff --git a/testsuite/tests/rename/should_fail/T19843h.stderr b/testsuite/tests/rename/should_fail/T19843h.stderr
index 43cf59befd..55d3fcdd96 100644
--- a/testsuite/tests/rename/should_fail/T19843h.stderr
+++ b/testsuite/tests/rename/should_fail/T19843h.stderr
@@ -2,7 +2,7 @@
T19843h.hs:14:7: error: [GHC-39999]
• No instance for ‘GHC.Records.HasField "mup" r4 a4’
arising from selecting the field ‘mup’
- Perhaps use ‘mop’ (line 11)
+ Perhaps use record field of A ‘mop’ (line 11)
• In the expression: undefined.mup
In an equation for ‘foo’: foo = undefined.mup
@@ -27,7 +27,7 @@ T19843h.hs:20:8: error: [GHC-39999]
T19843h.hs:24:8: error: [GHC-39999]
• No instance for ‘GHC.Records.HasField "getAll" r0 a0’
arising from selecting the field ‘getAll’
- Perhaps use ‘getAlt’ (imported from Data.Monoid)
+ Perhaps use record field of Alt ‘getAlt’ (imported from Data.Monoid)
Perhaps you want to add ‘getAll’ to the import list
in the import of ‘Data.Monoid’ (T19843h.hs:9:1-28).
• In the expression: undefined.getAll
diff --git a/testsuite/tests/rename/should_fail/T21605a.stderr b/testsuite/tests/rename/should_fail/T21605a.stderr
index 7be47098df..ce199cfb8f 100644
--- a/testsuite/tests/rename/should_fail/T21605a.stderr
+++ b/testsuite/tests/rename/should_fail/T21605a.stderr
@@ -4,7 +4,6 @@ T21605a.hs:5:13: error: [GHC-76037]
NB: the module ‘Prelude’ does not export ‘true’.
Suggested fix:
Perhaps use one of these:
+ data constructor ‘Prelude.True’ (imported from Prelude),
type constructor or class ‘Prelude.Num’ (imported from Prelude),
- type constructor or class ‘Prelude.Ord’ (imported from Prelude),
- type constructor or class ‘Prelude.Enum’ (imported from Prelude)
-
+ type constructor or class ‘Prelude.Ord’ (imported from Prelude)
diff --git a/testsuite/tests/rename/should_fail/T21605d.stderr b/testsuite/tests/rename/should_fail/T21605d.stderr
index 3db644aa93..0c0c3975af 100644
--- a/testsuite/tests/rename/should_fail/T21605d.stderr
+++ b/testsuite/tests/rename/should_fail/T21605d.stderr
@@ -1,8 +1,9 @@
-T21605d.hs:3:9: [GHC-37479]
+
+T21605d.hs:3:9: error: [GHC-37479]
‘Prelude.id’ is a term-level binding
and can not be used at the type level.
Suggested fix:
Perhaps use one of these:
+ data constructor ‘Prelude.EQ’ (imported from Prelude),
type constructor or class ‘Prelude.Eq’ (imported from Prelude),
- type constructor or class ‘Prelude.IO’ (imported from Prelude),
- type constructor or class ‘Prelude.Ord’ (imported from Prelude) \ No newline at end of file
+ data constructor ‘Prelude.GT’ (imported from Prelude)
diff --git a/testsuite/tests/rename/should_fail/T7943.hs b/testsuite/tests/rename/should_fail/T7943.hs
index a1a99d508a..335cb350c7 100644
--- a/testsuite/tests/rename/should_fail/T7943.hs
+++ b/testsuite/tests/rename/should_fail/T7943.hs
@@ -1,4 +1,4 @@
module T7943 where
data Foo = A { bar :: String }
- | B String { bar :: String }
+ | B String { bar :: String }
diff --git a/testsuite/tests/rename/should_fail/T7943.stderr b/testsuite/tests/rename/should_fail/T7943.stderr
index 3100928e51..352d4c1f40 100644
--- a/testsuite/tests/rename/should_fail/T7943.stderr
+++ b/testsuite/tests/rename/should_fail/T7943.stderr
@@ -1,6 +1,3 @@
-T7943.hs:4:22: error: [GHC-89246]
- • Record syntax is illegal here: {bar :: String}
- • In the type ‘{bar :: String}’
- In the definition of data constructor ‘B’
- In the data declaration for ‘Foo’
+T7943.hs:4:21: error: [GHC-89246]
+ Record syntax is illegal here: {bar :: String}
diff --git a/testsuite/tests/rename/should_fail/T9077.stderr b/testsuite/tests/rename/should_fail/T9077.stderr
index a3a9d49ece..c20800b12f 100644
--- a/testsuite/tests/rename/should_fail/T9077.stderr
+++ b/testsuite/tests/rename/should_fail/T9077.stderr
@@ -1,2 +1,2 @@
-T9077.hs:3:12: Record syntax is illegal here: {}
+T9077.hs:3:12: error: [GHC-89246] Record syntax is illegal here: {}
diff --git a/testsuite/tests/rename/should_fail/T9156.stderr b/testsuite/tests/rename/should_fail/T9156.stderr
index 361ed379df..1dbfb9b02e 100644
--- a/testsuite/tests/rename/should_fail/T9156.stderr
+++ b/testsuite/tests/rename/should_fail/T9156.stderr
@@ -1,5 +1,3 @@
-T9156.hs:4:19:
- Multiple declarations of ‘f1’
- Declared at: T9156.hs:3:15
- T9156.hs:4:19
+T9156.hs:4:19: error: [GHC-85524]
+ Duplicate field name ‘f1’ in record declaration
diff --git a/testsuite/tests/rename/should_fail/T9156_DF.hs b/testsuite/tests/rename/should_fail/T9156_DF.hs
new file mode 100644
index 0000000000..aa55756c71
--- /dev/null
+++ b/testsuite/tests/rename/should_fail/T9156_DF.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module T9156_DF where
+
+data X = MkX
+
+data family D a
+data instance D Int
+ = D1 { f1 :: X }
+ | D2 { f1 :: X, f2 :: X, f1 :: X }
diff --git a/testsuite/tests/rename/should_fail/T9156_DF.stderr b/testsuite/tests/rename/should_fail/T9156_DF.stderr
new file mode 100644
index 0000000000..61e2af19a4
--- /dev/null
+++ b/testsuite/tests/rename/should_fail/T9156_DF.stderr
@@ -0,0 +1,3 @@
+
+T9156_DF.hs:10:29: error: [GHC-85524]
+ Duplicate field name ‘f1’ in record declaration
diff --git a/testsuite/tests/rename/should_fail/all.T b/testsuite/tests/rename/should_fail/all.T
index 2255117886..8d3029bd06 100644
--- a/testsuite/tests/rename/should_fail/all.T
+++ b/testsuite/tests/rename/should_fail/all.T
@@ -104,6 +104,7 @@ test('RnStaticPointersFail02', [], compile_fail, [''])
test('RnStaticPointersFail03', [], compile_fail, ['-dsuppress-uniques'])
test('T9006', [], multimod_compile_fail, ['T9006', '-v0'])
test('T9156', normal, compile_fail, [''])
+test('T9156_DF', normal, compile_fail, [''])
test('T9177', normal, compile_fail, [''])
test('T9177a', normal, compile_fail, [''])
test('T9436', normal, compile_fail, [''])
diff --git a/testsuite/tests/rename/should_fail/rn_dup.hs b/testsuite/tests/rename/should_fail/rn_dup.hs
index 927e15ff32..7c2fc3380e 100644
--- a/testsuite/tests/rename/should_fail/rn_dup.hs
+++ b/testsuite/tests/rename/should_fail/rn_dup.hs
@@ -12,7 +12,7 @@ data P = MkP { rf :: Int, rf :: Int }
data Q = MkQ { rf :: Int }
class C a where
- data CT a
+ data CT a
f :: CT a -> a
data CT a
f :: CT a -> a
diff --git a/testsuite/tests/rename/should_fail/rn_dup.stderr b/testsuite/tests/rename/should_fail/rn_dup.stderr
index 5c4246d8b6..907fc38fe8 100644
--- a/testsuite/tests/rename/should_fail/rn_dup.stderr
+++ b/testsuite/tests/rename/should_fail/rn_dup.stderr
@@ -9,14 +9,12 @@ rn_dup.hs:9:10: error:
Declared at: rn_dup.hs:7:10
rn_dup.hs:9:10
-rn_dup.hs:12:16: error:
- Multiple declarations of ‘rf’
- Declared at: rn_dup.hs:11:27
- rn_dup.hs:12:16
+rn_dup.hs:11:27: error: [GHC-85524]
+ Duplicate field name ‘rf’ in record declaration
rn_dup.hs:12:16: error:
Multiple declarations of ‘rf’
- Declared at: rn_dup.hs:11:16
+ Declared at: rn_dup.hs:11:27
rn_dup.hs:12:16
rn_dup.hs:17:3: error:
diff --git a/testsuite/tests/rename/should_fail/rnfail054.stderr b/testsuite/tests/rename/should_fail/rnfail054.stderr
index 04fff51118..3cb01c63da 100644
--- a/testsuite/tests/rename/should_fail/rnfail054.stderr
+++ b/testsuite/tests/rename/should_fail/rnfail054.stderr
@@ -1,5 +1,3 @@
-rnfail054.hs:6:13: error: [GHC-47535]
- • ‘foo’ is not a record selector
- • In the expression: x {foo = 1}
- In an equation for ‘foo’: foo x = x {foo = 1}
+rnfail054.hs:6:13: error: [GHC-22385]
+ Not in scope: record field ‘foo’