summaryrefslogtreecommitdiff
path: root/testsuite/tests/deriving/should_compile/all.T
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2019-10-08 14:37:00 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-09 16:21:50 -0400
commitd584e3f08cfee6e28b70bf53c573d86e44f326f8 (patch)
tree289b0d0128e1cfae35321ddf1c9489d85ede4c7e /testsuite/tests/deriving/should_compile/all.T
parent35cc5eff3d54bacf626ecf0b6e0a1d660cbd6ba9 (diff)
downloadhaskell-d584e3f08cfee6e28b70bf53c573d86e44f326f8.tar.gz
Use addUsedDataCons more judiciously in TcDeriv (#17324)
If you derive an instance like this: ```hs deriving <...> instance Foo C ``` And the data constructors for `C` aren't in scope, then `doDerivInstErrorChecks1` throws an error. Moreover, it will _only_ throw an error if `<...>` is either `stock` or `newtype`. This is because the code that the `anyclass` or `via` strategies would generate would not require the use of the data constructors for `C`. However, `doDerivInstErrorChecks1` has another purpose. If you write this: ```hs import M (C(MkC1, ..., MkCn)) deriving <...> instance Foo C ``` Then `doDerivInstErrorChecks1` will call `addUsedDataCons` on `MkC1` through `MkCn` to ensure that `-Wunused-imports` does not complain about them. However, `doDerivInstErrorChecks1` was doing this for _every_ deriving strategy, which mean that if `<...>` were `anyclass` or `via`, then the warning about `MkC1` through `MkCn` being unused would be suppressed! The fix is simple enough: only call `addUsedDataCons` when the strategy is `stock` or `newtype`, just like the other code paths in `doDerivInstErrorChecks1`. Fixes #17324.
Diffstat (limited to 'testsuite/tests/deriving/should_compile/all.T')
-rw-r--r--testsuite/tests/deriving/should_compile/all.T1
1 files changed, 1 insertions, 0 deletions
diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T
index a12cf95c28..04fd02518f 100644
--- a/testsuite/tests/deriving/should_compile/all.T
+++ b/testsuite/tests/deriving/should_compile/all.T
@@ -118,3 +118,4 @@ test('T15637', normal, compile, [''])
test('T15831', normal, compile, [''])
test('T16179', normal, compile, [''])
test('T16518', normal, compile, [''])
+test('T17324', normal, compile, [''])