[commit: ghc] master: Lint types in newFamInst (257c13d)
git at git.haskell.org
git at git.haskell.org
Fri Apr 20 03:00:39 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/257c13d86db0a9ed540287127fd1c79abacf857e/ghc
>---------------------------------------------------------------
commit 257c13d86db0a9ed540287127fd1c79abacf857e
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date: Thu Apr 19 20:47:48 2018 -0400
Lint types in newFamInst
We weren't linting the types used in `newFamInst`, which
might have been why #15012 went undiscovered for so long. Let's fix
that.
One has to be surprisingly careful with expanding type synonyms in
`lintType`, since in the offending program (simplified):
```lang=haskell
type FakeOut a = Int
type family TF a
type instance TF Int = FakeOut a
```
If one expands type synonyms, then `FakeOut a` will expand to
`Int`, which masks the issue (that `a` is unbound). I added an
extra Lint flag to configure whether type synonyms should be
expanded or not in Lint, and disabled this when calling `lintTypes`
from `newFamInst`.
As evidence that this works, I ran it on the offending program
from #15012, and voilà:
```
$ ghc3/inplace/bin/ghc-stage2 Bug.hs -dcore-lint
[1 of 1] Compiling Foo ( Bug.hs, Bug.o )
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.5.20180417 for x86_64-unknown-linux):
Core Lint error
<no location info>: warning:
In the type ‘... (Rec0 (FakeOut b_a1Qt))))’
@ b_a1Qt is out of scope
```
Test Plan: make test TEST=T15057
Reviewers: simonpj, goldfire, bgamari
Reviewed By: bgamari
Subscribers: thomie, carter
GHC Trac Issues: #15057
Differential Revision: https://phabricator.haskell.org/D4611
>---------------------------------------------------------------
257c13d86db0a9ed540287127fd1c79abacf857e
compiler/coreSyn/CoreLint.hs | 112 +++++++++++++++------
compiler/typecheck/FamInst.hs | 16 ++-
.../tests/indexed-types/should_compile/T15057.hs | 11 ++
testsuite/tests/indexed-types/should_compile/all.T | 1 +
4 files changed, 109 insertions(+), 31 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 257c13d86db0a9ed540287127fd1c79abacf857e
More information about the ghc-commits
mailing list