Implement -Wredundant-bang-patterns (#17340)
Add new flag '-Wredundant-bang-patterns' that enables checks for "dead" bangs. Dead bangs are the ones that under no circumstances can force a thunk that wasn't already forced. Dead bangs are a form of redundant bangs. The new check is performed in Pattern-Match Coverage Checker along with other checks (namely, redundant and inaccessible RHSs). Given f :: Bool -> Int f True = 1 f !x = 2 we can detect dead bang patterns by checking whether @x ~ ⊥@ is satisfiable where the PmBang appears in 'checkGrdTree'. If not, then clearly the bang is dead. Such a dead bang is then indicated in the annotated pattern-match tree by a 'RedundantSrcBang' wrapping. In 'redundantAndInaccessibles', we collect all dead bangs to warn about. Note that we don't want to warn for a dead bang that appears on a redundant clause. That is because in that case, we recommend to delete the clause wholly, including its leading pattern match. Dead bang patterns are redundant. But there are bang patterns which are redundant that aren't dead, for example f !() = 0 the bang still forces the match variable, before we attempt to match on (). But it is redundant with the forcing done by the () match. We currently don't detect redundant bangs that aren't dead.
Status | Job ID | Name | Coverage | ||||||
---|---|---|---|---|---|---|---|---|---|
Lint | |||||||||
passed |
#418586
lint
|
ghc-linters |
00:01:03
|
|
|||||
passed |
#418587
lint
|
lint-linters |
00:01:08
|
|
|||||
passed |
#418590
lint
|
lint-submods |
00:00:21
|
|
|||||
passed |
#418588
lint
|
lint-testsuite |
00:00:16
|
|
|||||
passed |
#418589
lint
|
typecheck-testsuite |
00:00:15
|
|
|||||
Quick Build | |||||||||
passed |
#418591
x86_64-linux
|
hadrian-ghc-in-ghci |
00:11:47
|
|
|||||
Build | |||||||||
passed |
#418592
x86_64-linux
|
validate-x86_64-linux-deb9-hadrian |
01:36:23
|
|
|||||
Full Build | |||||||||
failed |
#418595
aarch64-linux
allowed to fail
|
validate-aarch64-linux-deb9 |
03:24:43
|
|
|||||
failed |
#418596
armv7-linux
allowed to fail
|
validate-armv7-linux-deb9 |
03:15:09
|
|
|||||
passed |
#418597
x86_64-linux
|
validate-i386-linux-deb9 |
01:31:39
|
|
|||||
passed |
#418594
x86_64-darwin
|
validate-x86_64-darwin |
01:09:50
|
|
|||||
passed |
#418598
x86_64-linux
|
validate-x86_64-linux-deb9-debug |
01:41:34
|
|
|||||
passed |
#418600
x86_64-linux
|
validate-x86_64-linux-deb9-dwarf |
01:20:33
|
|
|||||
passed |
#418599
x86_64-linux
|
validate-x86_64-linux-deb9-integer-simple |
01:33:57
|
|
|||||
passed |
#418593
x86_64-linux
|
validate-x86_64-linux-deb9-unreg-hadrian |
02:37:09
|
|
|||||
passed |
#418601
x86_64-linux
|
validate-x86_64-linux-fedora27 |
01:53:11
|
|
|||||
failed |
#418603
new-x86_64-windows
test
allowed to fail
|
validate-x86_64-windows |
00:30:19
|
|
|||||
failed |
#418602
new-x86_64-windows
test
allowed to fail
|
validate-x86_64-windows-hadrian |
03:27:49
|
|
|||||
Cleanup | |||||||||
passed |
#418604
x86_64-darwin
|
cleanup-darwin |
00:00:15
|
|
|||||
Packaging | |||||||||
failed |
#418605
x86_64-linux
allowed to fail
|
doc-tarball |
00:02:12
|
|
|||||
Testing | |||||||||
manual |
#418606
x86_64-linux
allowed to fail
manual
|
hackage |
|
||||||
passed |
#418607
x86_64-linux
|
perf-nofib |
00:21:29
|
|
|||||
Name | Stage | Failure | ||
---|---|---|---|---|
failed
|
validate-aarch64-linux-deb9 | Full Build | ||
|
||||
failed
|
validate-x86_64-windows | Full Build | ||
|
||||
failed
|
validate-armv7-linux-deb9 | Full Build | ||
|
||||
failed
|
validate-x86_64-windows-hadrian | Full Build | ||
|
||||
failed
|
doc-tarball | Packaging | ||
|