diff options
author | Kari Pahula <kaol@iki.fi> | 2019-09-24 16:33:15 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-09-25 13:52:48 -0400 |
commit | 2970dc7ab95f7daa793112c6a4a682263561761c (patch) | |
tree | bcbc7c565479441427e5e512b6c71d85ce6d497e /testsuite/tests | |
parent | 218c5dbfbd60a416588e1b952c167ebd18ef9c56 (diff) | |
download | haskell-2970dc7ab95f7daa793112c6a4a682263561761c.tar.gz |
Add -Wderiving-defaults (#15839)
Enabling both DeriveAnyClass and GeneralizedNewtypeDeriving can cause
a warning when no explicit deriving strategy is in use. This change adds
an enable/suppress flag for it.
Diffstat (limited to 'testsuite/tests')
5 files changed, 26 insertions, 3 deletions
diff --git a/testsuite/tests/deriving/should_compile/T16179.stderr b/testsuite/tests/deriving/should_compile/T16179.stderr index c3815d138f..ae40e85a0e 100644 --- a/testsuite/tests/deriving/should_compile/T16179.stderr +++ b/testsuite/tests/deriving/should_compile/T16179.stderr @@ -1,5 +1,6 @@ -T16179.hs:7:30: warning: - Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled + +T16179.hs:7:30: warning: [-Wderiving-defaults (in -Wdefault)] + • 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’ + • In the newtype declaration for ‘T’ diff --git a/testsuite/tests/typecheck/should_compile/T15839a.hs b/testsuite/tests/typecheck/should_compile/T15839a.hs new file mode 100644 index 0000000000..28763aa971 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T15839a.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE DeriveAnyClass, GeneralizedNewtypeDeriving #-} + +module T15839a () where + +class C a +newtype T a = MkT a deriving C diff --git a/testsuite/tests/typecheck/should_compile/T15839a.stderr b/testsuite/tests/typecheck/should_compile/T15839a.stderr new file mode 100644 index 0000000000..b4aef83367 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T15839a.stderr @@ -0,0 +1,6 @@ + +T15839a.hs:6:30: warning: [-Wderiving-defaults (in -Wdefault)] + • 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/typecheck/should_compile/T15839b.hs b/testsuite/tests/typecheck/should_compile/T15839b.hs new file mode 100644 index 0000000000..02b9bfbd9b --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T15839b.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE DeriveAnyClass, GeneralizedNewtypeDeriving #-} + +{-# OPTIONS_GHC -Wno-deriving-defaults #-} + +module T15839a () where + +class C a +newtype T a = MkT a deriving C diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index e359f8db6b..30a64518fe 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -689,3 +689,5 @@ test('T16946', normal, compile, ['']) test('T17007', normal, compile, ['']) test('T17067', normal, compile, ['']) test('T17202', expect_broken(17202), compile, ['']) +test('T15839a', normal, compile, ['']) +test('T15839b', normal, compile, ['']) |