summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChaitanya Koparkar <ckoparkar@gmail.com>2019-01-14 14:36:29 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-01-20 05:24:59 -0500
commit800d77e882f24066a7f6d818b2606ad8a0e79e02 (patch)
tree6e7d9b4673499c1cb29214641571f27e8c32a2e8
parentb137ab75ab269e043e0783e41ac704d1be5570c6 (diff)
downloadhaskell-800d77e882f24066a7f6d818b2606ad8a0e79e02.tar.gz
Mention DerivingStrategies in the warning when DAC and GND are both enabled
Summary: When DeriveAnyClass and GeneralizedNewtypeDeriving are both enabled, GHC prints out a warning that specifies the strategy it used to derive a class. This patch updates the warning to mention that users may pick a particular strategy by using DerivingStrategies. Test plan: make test TEST=T16179
-rw-r--r--compiler/typecheck/TcDeriv.hs5
-rw-r--r--testsuite/tests/deriving/should_compile/T16179.hs7
-rw-r--r--testsuite/tests/deriving/should_compile/T16179.stderr5
-rw-r--r--testsuite/tests/deriving/should_compile/all.T1
4 files changed, 17 insertions, 1 deletions
diff --git a/compiler/typecheck/TcDeriv.hs b/compiler/typecheck/TcDeriv.hs
index 90b230a972..6078a7a7ff 100644
--- a/compiler/typecheck/TcDeriv.hs
+++ b/compiler/typecheck/TcDeriv.hs
@@ -1640,7 +1640,10 @@ mkNewTypeEqn
[ text "Both DeriveAnyClass and"
<+> text "GeneralizedNewtypeDeriving are enabled"
, text "Defaulting to the DeriveAnyClass strategy"
- <+> text "for instantiating" <+> ppr cls ]
+ <+> text "for instantiating" <+> ppr cls
+ , text "Use DerivingStrategies to pick"
+ <+> text "a different strategy"
+ ]
mk_originative_eqn DerivSpecAnyClass
-- CanDeriveStock
CanDeriveStock gen_fn -> mk_originative_eqn $
diff --git a/testsuite/tests/deriving/should_compile/T16179.hs b/testsuite/tests/deriving/should_compile/T16179.hs
new file mode 100644
index 0000000000..5873f8913e
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T16179.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE DeriveAnyClass #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
+module T16179 where
+
+class C a
+newtype T a = MkT a deriving C
diff --git a/testsuite/tests/deriving/should_compile/T16179.stderr b/testsuite/tests/deriving/should_compile/T16179.stderr
new file mode 100644
index 0000000000..c3815d138f
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T16179.stderr
@@ -0,0 +1,5 @@
+T16179.hs:7:30: warning:
+ Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled
+ Defaulting to the DeriveAnyClass strategy for instantiating C
+ Use DerivingStrategies to pick a different strategy
+ In the newtype declaration for ‘T’
diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T
index 8c84bcc31a..ef6259df54 100644
--- a/testsuite/tests/deriving/should_compile/all.T
+++ b/testsuite/tests/deriving/should_compile/all.T
@@ -114,3 +114,4 @@ test('T15290c', normal, compile, [''])
test('T15290d', normal, compile, [''])
test('T15398', normal, compile, [''])
test('T15637', normal, compile, [''])
+test('T16179', normal, compile, [''])