diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2018-06-16 23:25:53 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2018-06-18 08:23:16 +0100 |
commit | d6216443c61cee94d8ffc31ca8510a534d9406b9 (patch) | |
tree | 21fba696d61323ff49ee4fb041f492435b8636f7 /testsuite/tests | |
parent | 50d7b2ac2fcfe954455f0bc9081e1dd3a2eef51d (diff) | |
download | haskell-d6216443c61cee94d8ffc31ca8510a534d9406b9.tar.gz |
Fix an infinite loop in niFixTCvSubst
Trac #14164 made GHC loop, a pretty serious error. It turned
out that Unify.niFixTCvSubst was looping forever, because we
had a substitution like
a :-> ....(b :: (c :: d))....
d :-> ...
We correctly recognised that d was free in the range of the
substitution, but then failed to apply it "deeeply enough"
to the range of the substiuttion, so d was /still/ free in
the range, and we kept on going.
Trac #9106 was caused by a similar problem, but alas my
fix to Trac #9106 was inadequate when the offending type
variable is more deeply buried. Urk.
This time I think I've fixed it! It's much more subtle
than I though, and it took most of a long train journey
to figure it out. I wrote a long note to explain:
Note [Finding the substitution fixpoint]
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/indexed-types/should_compile/T14164.hs | 10 | ||||
-rw-r--r-- | testsuite/tests/indexed-types/should_compile/all.T | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/testsuite/tests/indexed-types/should_compile/T14164.hs b/testsuite/tests/indexed-types/should_compile/T14164.hs new file mode 100644 index 0000000000..1cf6f2d78b --- /dev/null +++ b/testsuite/tests/indexed-types/should_compile/T14164.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE TypeFamilyDependencies #-}
+{-# LANGUAGE TypeInType #-}
+{-# LANGUAGE TypeOperators #-}
+module T14164 where
+
+data G (x :: a) = GNil | GCons (G x)
+
+type family F (xs :: [a]) (g :: G (z :: a)) = (res :: [a]) | res -> a where
+ F (x:xs) GNil = x:xs
+ F (x:xs) (GCons rest) = x:F xs rest
diff --git a/testsuite/tests/indexed-types/should_compile/all.T b/testsuite/tests/indexed-types/should_compile/all.T index c58424fd7a..56448ac75b 100644 --- a/testsuite/tests/indexed-types/should_compile/all.T +++ b/testsuite/tests/indexed-types/should_compile/all.T @@ -283,3 +283,4 @@ test('T15057', normal, compile, ['']) test('T15144', normal, compile, ['']) test('T15122', normal, compile, ['']) test('T13777', normal, compile, ['']) +test('T14164', normal, compile, ['']) |