Commit 9e5535ca authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Fix OptCoercion

In the presence of -fdefer-type-errors, OptCoercion can
encounter a mal-formed coerercion with type
    T a ~ T a b
and that was causing a subsequent Lint error.

This caused Trac #14607.  Easily fixed by turning an ASSERT
into a guard.
parent 112266ce
......@@ -934,8 +934,10 @@ etaTyConAppCo_maybe tc co
, tc1 == tc2
, isInjectiveTyCon tc r -- See Note [NthCo and newtypes] in TyCoRep
, let n = length tys1
, tys2 `lengthIs` n -- This can fail in an erroneous progam
-- E.g. T a ~# T a b
-- Trac #14607
= ASSERT( tc == tc1 )
ASSERT( tys2 `lengthIs` n )
Just (decomposeCo n co)
-- NB: n might be <> tyConArity tc
-- e.g. data family T a :: * -> *
......
{-# OPTIONS_GHC -fdefer-type-errors #-}
-- This line is crucial to the bug
{-# Language GADTs #-}
{-# Language InstanceSigs #-}
{-# Language KindSignatures #-}
{-# Language TypeFamilies #-}
{-# Language DataKinds #-}
{-# Language FlexibleInstances #-}
module T14607 where
import Data.Kind
data LamCons :: Type -> Type -> () -> Type where
C :: LamCons a a '()
class Mk a where
mk :: LamCons a a '()
instance Mk a where
mk :: LamCons a '()
mk = mk
T14607.hs:22:9: warning: [-Wdeferred-type-errors (in -Wdefault)]
• Expecting one more argument to ‘LamCons a '()’
Expected a type, but ‘LamCons a '()’ has kind ‘() -> *’
• In the type signature: mk :: LamCons a '()
In the instance declaration for ‘Mk a’
T14607.hs:22:19: warning: [-Wdeferred-type-errors (in -Wdefault)]
• Expected a type, but ‘ '()’ has kind ‘()’
• In the second argument of ‘LamCons’, namely ‘ '()’
In the type signature: mk :: LamCons a '()
In the instance declaration for ‘Mk a’
T14607.hs:23:8: warning: [-Wdeferred-type-errors (in -Wdefault)]
• Couldn't match expected type ‘LamCons a '()’
with actual type ‘LamCons a0 a0 '()’
• In the expression: mk
In an equation for ‘mk’: mk = mk
In the instance declaration for ‘Mk a’
• Relevant bindings include
mk :: LamCons a '() (bound at T14607.hs:23:3)
......@@ -463,3 +463,4 @@ test('T14350', normal, compile_fail, [''])
test('T14390', normal, compile_fail, [''])
test('MissingExportList03', normal, compile_fail, [''])
test('T14618', normal, compile_fail, [''])
test('T14607', normal, compile, [''])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment