[commit: ghc] wip/T16191: Control validity-checking of type synonym applications more carefully (9dc56b6)
git at git.haskell.org
git at git.haskell.org
Wed Jan 16 18:22:45 UTC 2019
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/T16191
Link : http://ghc.haskell.org/trac/ghc/changeset/9dc56b61ae10cb26ec8b2bc132ae6c9b620707a8/ghc
>---------------------------------------------------------------
commit 9dc56b61ae10cb26ec8b2bc132ae6c9b620707a8
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date: Thu Jan 10 16:55:51 2019 -0500
Control validity-checking of type synonym applications more carefully
Trac #16059 shows that when validity checking applications of type
synonyms, GHC sometimes wasn't checking the expanded type enough.
We must be careful, however, since checking both the expanded type as
well as the arguments to the type synonym can lead to exponential
blowup (see https://ghc.haskell.org/trac/ghc/ticket/16059#comment:4).
Nor can we omit checking either the expanded type or the argument for
correctness reasons.
The solution here is to introduce a new `ExpandMode` data type that
is plumbed through all of the type-validity-checking functions in
`TcValidity`. `ExpandMode` dictates whether we only check the
expanded type (`Expand`), only check the arguments (`NoExpand), or
both (`Both`). Importantly, if we check `Both` in the function for
validity checking type synonym applications, then we switch to
`NoExpand` when checking the arguments so as to avoid exponential
blowup. See `Note [Correctness and performance of type synonym validity
checking]` for the full story.
>---------------------------------------------------------------
9dc56b61ae10cb26ec8b2bc132ae6c9b620707a8
compiler/typecheck/TcValidity.hs | 241 ++++++++++++++++-----
testsuite/tests/safeHaskell/unsafeLibs/Dep05.hs | 1 +
.../tests/safeHaskell/unsafeLibs/Dep05.stderr | 2 +-
testsuite/tests/typecheck/should_fail/T16059a.hs | 12 +
.../tests/typecheck/should_fail/T16059a.stderr | 9 +
testsuite/tests/typecheck/should_fail/T16059b.hs | 6 +
testsuite/tests/typecheck/should_fail/T16059c.hs | 6 +
.../tests/typecheck/should_fail/T16059c.stderr | 6 +
testsuite/tests/typecheck/should_fail/T16059d.hs | 5 +
.../tests/typecheck/should_fail/T16059d.stderr | 6 +
testsuite/tests/typecheck/should_fail/T16059e.hs | 15 ++
.../tests/typecheck/should_fail/T16059e.stderr | 7 +
.../tests/typecheck/should_fail/T9858a.stderr | 18 +-
testsuite/tests/typecheck/should_fail/all.T | 7 +
14 files changed, 271 insertions(+), 70 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 9dc56b61ae10cb26ec8b2bc132ae6c9b620707a8
More information about the ghc-commits
mailing list