[commit: ghc] wip/ghc-8.8-merges: Mention DerivingStrategies in the warning when DAC and GND are both enabled (2420b36)
git at git.haskell.org
git at git.haskell.org
Thu Feb 21 15:10:42 UTC 2019
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/ghc-8.8-merges
Link : http://ghc.haskell.org/trac/ghc/changeset/2420b368f31f350601db2e38c2e059b4e372ddf6/ghc
>---------------------------------------------------------------
commit 2420b368f31f350601db2e38c2e059b4e372ddf6
Author: Chaitanya Koparkar <ckoparkar at gmail.com>
Date: Mon Jan 14 14:36:29 2019 -0500
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
>---------------------------------------------------------------
2420b368f31f350601db2e38c2e059b4e372ddf6
compiler/typecheck/TcDeriv.hs | 5 ++++-
testsuite/tests/deriving/should_compile/T16179.hs | 7 +++++++
testsuite/tests/deriving/should_compile/T16179.stderr | 5 +++++
testsuite/tests/deriving/should_compile/all.T | 1 +
4 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/compiler/typecheck/TcDeriv.hs b/compiler/typecheck/TcDeriv.hs
index 90b230a..6078a7a 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 0000000..5873f89
--- /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 0000000..c3815d1
--- /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 8c84bcc..ef6259d 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, [''])
More information about the ghc-commits
mailing list