summaryrefslogtreecommitdiff
path: root/testsuite/tests/generics
diff options
context:
space:
mode:
authorAlfredo Di Napoli <alfredo@well-typed.com>2021-09-20 15:51:21 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-05 14:34:04 -0400
commitac275f4237f1e4030c8b7b9e81e2d563e6903a81 (patch)
tree25786972e31bb6490b0558ee07d257d3135f3cb7 /testsuite/tests/generics
parentf52df067d288a023c52c4387841fe12a37bd1263 (diff)
downloadhaskell-ac275f4237f1e4030c8b7b9e81e2d563e6903a81.tar.gz
Eradicate TcRnUnknownMessage from GHC.Tc.Deriv
This (big) commit finishes porting the GHC.Tc.Deriv module to support the new diagnostic infrastructure (#18516) by getting rid of the legacy calls to `TcRnUnknownMessage`. This work ended up being quite pervasive and touched not only the Tc.Deriv module but also the Tc.Deriv.Utils and Tc.Deriv.Generics module, which needed to be adapted to use the new infrastructure. This also required generalising `Validity`. More specifically, this is a breakdown of the work done: * Add and use the TcRnUselessTypeable data constructor * Add and use TcRnDerivingDefaults data constructor * Add and use the TcRnNonUnaryTypeclassConstraint data constructor * Add and use TcRnPartialTypeSignatures * Add T13324_compile2 test to test another part of the TcRnPartialTypeSignatures diagnostic * Add and use TcRnCannotDeriveInstance data constructor, which introduces a new data constructor to TcRnMessage called TcRnCannotDeriveInstance, which is further sub-divided to carry a `DeriveInstanceErrReason` which explains the reason why we couldn't derive a typeclass instance. * Add DerivErrSafeHaskellGenericInst data constructor to DeriveInstanceErrReason * Add DerivErrDerivingViaWrongKind and DerivErrNoEtaReduce * Introduce the SuggestExtensionInOrderTo Hint, which adds (and use) a new constructor to the hint type `LanguageExtensionHint` called `SuggestExtensionInOrderTo`, which can be used to give a bit more "firm" recommendations when it's obvious what the required extension is, like in the case for the `DerivingStrategies`, which automatically follows from having enabled both `DeriveAnyClass` and `GeneralizedNewtypeDeriving`. * Wildcard-free pattern matching in mk_eqn_stock, which removes `_` in favour of pattern matching explicitly on `CanDeriveAnyClass` and `NonDerivableClass`, because that determine whether or not we can suggest to the user `DeriveAnyClass` or not.
Diffstat (limited to 'testsuite/tests/generics')
-rw-r--r--testsuite/tests/generics/GenCannotDoRep0_0.stderr2
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_0.stderr2
-rw-r--r--testsuite/tests/generics/T10604/T10604_no_PolyKinds.stderr2
-rw-r--r--testsuite/tests/generics/T5462No1.stderr8
4 files changed, 8 insertions, 6 deletions
diff --git a/testsuite/tests/generics/GenCannotDoRep0_0.stderr b/testsuite/tests/generics/GenCannotDoRep0_0.stderr
index c808430dde..ced307d7c9 100644
--- a/testsuite/tests/generics/GenCannotDoRep0_0.stderr
+++ b/testsuite/tests/generics/GenCannotDoRep0_0.stderr
@@ -5,8 +5,8 @@ GenCannotDoRep0_0.hs:6:14: warning: [-Wdeprecated-flags (in -Wdefault)]
GenCannotDoRep0_0.hs:13:45: error:
• Can't make a derived instance of ‘Generic Dynamic’:
Constructor ‘Dynamic’ has existential type variables in its type
- Possible fix: use a standalone deriving declaration instead
• In the data declaration for ‘Dynamic’
+ Suggested fix: Use a standalone deriving declaration instead
GenCannotDoRep0_0.hs:28:1: error:
• Can't make a derived instance of ‘Generic (D Int a)’:
diff --git a/testsuite/tests/generics/GenCannotDoRep1_0.stderr b/testsuite/tests/generics/GenCannotDoRep1_0.stderr
index 1a576e6cb1..604ad0c14c 100644
--- a/testsuite/tests/generics/GenCannotDoRep1_0.stderr
+++ b/testsuite/tests/generics/GenCannotDoRep1_0.stderr
@@ -2,5 +2,5 @@
GenCannotDoRep1_0.hs:9:49: error:
• Can't make a derived instance of ‘Generic1 Dynamic’:
Constructor ‘Dynamic’ has existential type variables in its type
- Possible fix: use a standalone deriving declaration instead
• In the data declaration for ‘Dynamic’
+ Suggested fix: Use a standalone deriving declaration instead
diff --git a/testsuite/tests/generics/T10604/T10604_no_PolyKinds.stderr b/testsuite/tests/generics/T10604/T10604_no_PolyKinds.stderr
index ca87502a90..1f1c2178f6 100644
--- a/testsuite/tests/generics/T10604/T10604_no_PolyKinds.stderr
+++ b/testsuite/tests/generics/T10604/T10604_no_PolyKinds.stderr
@@ -1,6 +1,6 @@
T10604_no_PolyKinds.hs:8:35: error:
• Cannot derive well-kinded instance of form ‘Generic1 (F ...)’
- (Perhaps you intended to use PolyKinds)
Class ‘Generic1’ expects an argument of kind ‘* -> *’
• In the data declaration for ‘F’
+ Suggested fix: Perhaps you intended to use PolyKinds
diff --git a/testsuite/tests/generics/T5462No1.stderr b/testsuite/tests/generics/T5462No1.stderr
index 0b718d648e..b4977caa23 100644
--- a/testsuite/tests/generics/T5462No1.stderr
+++ b/testsuite/tests/generics/T5462No1.stderr
@@ -4,17 +4,19 @@
T5462No1.hs:25:42: error:
• Can't make a derived instance of ‘GFunctor F’:
‘GFunctor’ is not a stock derivable class (Eq, Show, etc.)
- Try GeneralizedNewtypeDeriving for GHC's newtype-deriving extension
• In the newtype declaration for ‘F’
+ Suggested fix:
+ Perhaps you intended to use GeneralizedNewtypeDeriving
+ for GHC's newtype-deriving extension
T5462No1.hs:27:23: error:
• Can't make a derived instance of ‘C1 G’:
‘C1’ is not a stock derivable class (Eq, Show, etc.)
- Try enabling DeriveAnyClass
• In the data declaration for ‘G’
+ Suggested fix: Perhaps you intended to use DeriveAnyClass
T5462No1.hs:28:23: error:
• Can't make a derived instance of ‘C2 H’:
‘C2’ is not a stock derivable class (Eq, Show, etc.)
- Try enabling DeriveAnyClass
• In the data declaration for ‘H’
+ Suggested fix: Perhaps you intended to use DeriveAnyClass