Typechecker hangs when checking type families with -ddump-tc-trace turned on
I have the following code, which is supposed to fail with a type error. However, when compiled with HEAD using the -ddump-tc-trace flag, the type checker hangs.
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
module Test where
import Data.Proxy
test :: (IsElem a as ~ 'True) => Proxy a -> Proxy as -> Bool
test _ _ = True
x = test (Proxy :: Proxy Int) (Proxy :: Proxy '[])
type family IsElem (x :: k) (xs :: [k]) where
IsElem x '[] = 'False
IsElem x (x ': xs) = 'True
IsElem x (y ': xs) = IsElem x xs
The reason is that in typecheck/TcHsType.hs, the type family tycons are type-checked with knot-tying, however, they are being traced, forcing their evaluation which causes the typechecker to hang.
My proposed fix is to only print the safe values that we know are constructed by the time of tracing.
Trac metadata
Trac field | Value |
---|---|
Version | 8.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |