summaryrefslogtreecommitdiff
path: root/testsuite/tests/deSugar/should_run/mc02.hs
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2019-10-08 14:37:00 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2019-10-08 14:39:56 -0400
commitc8005e42f927869b41e47ac1da3be86362171569 (patch)
tree29139bd513791517bed88ad6d78ba117651b4cba /testsuite/tests/deSugar/should_run/mc02.hs
parentf691f0c21dcc576e02313123e8b091e241d23b51 (diff)
downloadhaskell-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/deSugar/should_run/mc02.hs')
0 files changed, 0 insertions, 0 deletions