diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-10-08 14:37:00 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-10-08 14:39:56 -0400 |
commit | c8005e42f927869b41e47ac1da3be86362171569 (patch) | |
tree | 29139bd513791517bed88ad6d78ba117651b4cba /testsuite/tests/mdo/should_fail/mdofail002.stderr-hugs | |
parent | f691f0c21dcc576e02313123e8b091e241d23b51 (diff) | |
download | haskell-wip/T17324.tar.gz |
Use addUsedDataCons more judiciously in TcDeriv (#17324)wip/T17324
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/mdo/should_fail/mdofail002.stderr-hugs')
0 files changed, 0 insertions, 0 deletions