Commit a2ce2609 authored by simonpj's avatar simonpj
Browse files

Test for GADT escape (I forget which Trac bug this is for, if any)

parent f038d224
......@@ -67,6 +67,7 @@ test('set', normal, compile, [''])
test('scoped', expect_broken(1823), compile, [''])
test('gadt-escape1', normal, compile_fail, [''])
# New ones from Dimitrios
{-# OPTIONS -XGADTs -XExistentialQuantification #-}
module Escape where
data ExpGADT t where
ExpInt :: Int -> ExpGADT Int
data Hidden = forall t . Hidden (ExpGADT t) (ExpGADT t)
hval = Hidden (ExpInt 0) (ExpInt 1)
-- With the type sig this is ok, but without it should
-- be rejected becuase the result type is wobbly
-- weird1 :: ExpGADT Int
weird1 = case (hval :: Hidden) of Hidden (ExpInt _) a -> a
weird2 :: ExpGADT Int
weird2 = case (hval :: Hidden) of Hidden (ExpInt _) a -> a
GADT pattern match with non-rigid result type `t'
Solution: add a type signature
In a case alternative: Hidden (ExpInt _) a -> a
In the expression:
case (hval :: Hidden) of Hidden (ExpInt _) a -> a
In the definition of `weird1':
weird1 = case (hval :: Hidden) of Hidden (ExpInt _) a -> a
Supports Markdown
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