Fix push_bang_into_newtype when the pattern match has no arguments
authorMatthew Pickering <matthewtpickering@gmail.com>
Wed, 8 Feb 2017 02:35:32 +0000 (21:35 -0500)
committerBen Gamari <ben@smart-cactus.org>
Wed, 8 Feb 2017 03:39:14 +0000 (22:39 -0500)
commit062f112388ac879dc78a9a0c5a947894d20cd899
treecf7cbda1f4a62cfbcd636db12ed5c0766950f7af
parentbc376d329ae2d727e9b88f2fcbc1a9315300a4fc
Fix push_bang_into_newtype when the pattern match has no arguments

Correct behaviour of push_bang_into_newtype when the pattern match has
no arguments. A user can write

```
newtype T = T Int

f :: T -> ()
f !(T {}) = ()
```
in which case we have to push the bang inwards through the newtype in
order to achieve the desired strictness properties. This patch fixes
this special case where the pattern match has no arguments to push the
bang onto. We now make up a wildcard pattern which is wrapped in the
bang pattern.

```
f (T !_) = ()
```

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: simonpj, thomie

Differential Revision: https://phabricator.haskell.org/D3057
compiler/deSugar/Match.hs
testsuite/tests/deSugar/should_compile/T13215.hs [new file with mode: 0644]
testsuite/tests/deSugar/should_compile/all.T
testsuite/tests/deSugar/should_run/T9844.hs
testsuite/tests/deSugar/should_run/T9844.stderr
testsuite/tests/deSugar/should_run/T9844.stdout