Commit 2ec07b32 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Test Trac #7748

parent 7440ff20
-- Correct type, which is inferred by GHC 7.6.1 and
-- works fine with GHC 7.6.2:
-- test :: Maybe (Maybe (r -> ())) -> r -> ()
-- Incorrect type, resulting in a runtime <<loop>>,
-- inferred by GHC 7.6.2 and also accepted by GHC 7.6.1:
-- test :: a -> r -> ()
module T7748a where
test :: a -> r -> ()
test zd
= let f = let g = case zd of
Nothing -> const ()
Just Nothing -> const ()
Just (Just p) -> p
in g
in f
{-
There is a bug in the type checker of 7.6.1 and 7.6.2, which accepts
an incorrect type resulting in <<loop>> at runtime. Furthermore, 7.6.2
even automatically infers this incorrect type. Hence, the attached
code has the following behavior:
- No explicit type: Code works in 7.6.1, loops in 7.6.2
- Correct explicit type: Code works fine in 7.6.1 and 7.6.2
- Incorrect explicit type: Code loops in 7.6.1 and 7.6.2
The incorrect type has a parameter that is too polymorphic, i.e. an
"a" type is accepted while the function does a pattern match on the
parameter from which it is clear that it should be a Maybe type. In
7.4.* versions this incorrect type is not accepted.
-}
\ No newline at end of file
T7748a.hs:14:24:
Couldn't match expected type ‛a’
with actual type ‛Maybe (Maybe (r -> ()))’
‛a’ is a rigid type variable bound by
the type signature for test :: a -> r -> () at T7748a.hs:11:9
Relevant bindings include
test :: a -> r -> () (bound at T7748a.hs:12:1)
zd :: a (bound at T7748a.hs:12:6)
f :: r -> () (bound at T7748a.hs:13:8)
g :: r -> () (bound at T7748a.hs:13:16)
In the pattern: Nothing
In a case alternative: Nothing -> const ()
In the expression:
case zd of {
Nothing -> const ()
Just Nothing -> const ()
Just (Just p) -> p }
......@@ -300,3 +300,4 @@ test('T2354', normal, compile_fail, ['-O'])
test('T7734', normal, compile_fail, [''])
test('T7697', normal, compile_fail, [''])
test('T7696', normal, compile_fail, [''])
test('T7748a', normal, compile_fail, [''])
-- Correct type, which is inferred by GHC 7.6.1 and
-- works fine with GHC 7.6.2:
-- test :: Maybe (Maybe (r -> ())) -> r -> ()
-- Incorrect type, resulting in a runtime <<loop>>,
-- inferred by GHC 7.6.2 and also accepted by GHC 7.6.1:
-- test :: a -> r -> ()
module Main where
test zd
= let f = let g = case zd of
Nothing -> const ()
Just Nothing -> const ()
Just (Just p) -> p
in g
in f
main :: IO ()
main = do
let x = test (Just Nothing) ()
print x
{-
There is a bug in the type checker of 7.6.1 and 7.6.2, which accepts
an incorrect type resulting in <<loop>> at runtime. Furthermore, 7.6.2
even automatically infers this incorrect type. Hence, the attached
code has the following behavior:
- No explicit type: Code works in 7.6.1, loops in 7.6.2
- Correct explicit type: Code works fine in 7.6.1 and 7.6.2
- Incorrect explicit type: Code loops in 7.6.1 and 7.6.2
The incorrect type has a parameter that is too polymorphic, i.e. an
"a" type is accepted while the function does a pattern match on the
parameter from which it is clear that it should be a Maybe type. In
7.4.* versions this incorrect type is not accepted.
-}
\ No newline at end of file
......@@ -107,3 +107,4 @@ test('T7126', normal, compile_and_run, [''])
test('T6117', normal, compile_and_run, [''])
test('T5751', normal, compile_and_run, [''])
test('T5913', normal, compile_and_run, [''])
test('T7748', normal, compile_and_run, [''])
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