Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
be72302b
Commit
be72302b
authored
Nov 12, 2010
by
Simon Peyton Jones
Browse files
Test "frozen" type errors
parent
a4d9a407
Changes
3
Hide whitespace changes
Inline
Side-by-side
testsuite/tests/ghc-regress/typecheck/should_fail/FrozenErrorTests.hs
0 → 100644
View file @
be72302b
{-# LANGUAGE RankNTypes, GADTs, TypeFamilies #-}
module
Test
where
data
T
a
where
MkT
::
a
->
T
a
MkT2
::
forall
a
b
.
(
b
~
T
b
)
=>
b
->
T
a
MkT3
::
forall
a
.
(
a
~
Bool
)
=>
T
a
-- Occurs checks in givens
foo
::
forall
a
.
(
a
~
T
a
)
=>
a
->
a
foo
x
=
x
blah
x
=
case
x
of
MkT2
y
->
()
-- Mismatches in givens
bloh
::
T
Int
->
()
bloh
x
=
case
x
of
MkT3
->
()
type
family
F
a
b
type
family
G
a
b
type
instance
F
a
Bool
=
a
type
instance
G
a
Char
=
a
goo1
::
forall
a
b
.
(
F
a
b
~
[
a
])
=>
b
->
a
->
a
goo1
=
undefined
goo2
::
forall
a
.
G
a
Char
~
[
Int
]
=>
a
->
a
goo2
=
undefined
-- Just an occurs check
test1
=
goo1
False
undefined
-- A frozen occurs check, now transformed to decomposition error
test2
=
goo2
(
goo1
False
undefined
)
test3
=
goo1
False
(
goo2
undefined
)
-- A frozen occurs check, now transformed to both a decomposition and occurs check
data
M
a
where
M
::
M
a
data
T2
a
b
where
T2
::
T2
a
b
goo3
::
forall
a
b
.
F
a
b
~
T2
(
M
a
)
a
=>
b
->
a
->
a
goo3
=
undefined
goo4
::
forall
a
c
.
G
a
Char
~
T2
(
T2
c
c
)
c
=>
a
->
a
goo4
=
undefined
test4
=
goo4
(
goo3
False
undefined
)
test5
=
goo3
False
(
goo4
undefined
)
testsuite/tests/ghc-regress/typecheck/should_fail/FrozenErrorTests.stderr
0 → 100644
View file @
be72302b
FrozenErrorTests.hs:11:1:
Couldn't match type `a' with `T a'
`a' is a rigid type variable bound by
the type signature for `foo' at FrozenErrorTests.hs:10:15
Inaccessible code in the type signature for `foo'
FrozenErrorTests.hs:14:12:
Couldn't match type `b' with `T b'
`b' is a rigid type variable bound by
a pattern with constructor MkT2 :: forall a b. b ~ T b => b -> T a
at FrozenErrorTests.hs:14:12
Inaccessible code in
a pattern with constructor `MkT2', in a case alternative
In the pattern: MkT2 y
In a case alternative: MkT2 y -> ()
In the expression: case x of { MkT2 y -> () }
FrozenErrorTests.hs:19:12:
Couldn't match type `Int' with `Bool'
Inaccessible code in
a pattern with constructor `MkT3', in a case alternative
In the pattern: MkT3
In a case alternative: MkT3 -> ()
In the expression: case x of { MkT3 -> () }
FrozenErrorTests.hs:33:9:
Occurs check: cannot construct the infinite type: a = [a]
Expected type: [a]
Actual type: F a Bool
In the expression: goo1 False undefined
In an equation for `test1': test1 = goo1 False undefined
FrozenErrorTests.hs:36:15:
Couldn't match type `Int' with `[Int]'
Expected type: [[Int]]
Actual type: F [Int] Bool
In the first argument of `goo2', namely `(goo1 False undefined)'
In the expression: goo2 (goo1 False undefined)
In an equation for `test2': test2 = goo2 (goo1 False undefined)
FrozenErrorTests.hs:37:9:
Couldn't match type `Int' with `[Int]'
Expected type: [[Int]]
Actual type: F [Int] Bool
In the expression: goo1 False (goo2 undefined)
In an equation for `test3': test3 = goo1 False (goo2 undefined)
FrozenErrorTests.hs:52:15:
Occurs check: cannot construct the infinite type: c = T2 (T2 c c) c
Expected type: T2 (M (T2 (T2 c c) c)) (T2 (T2 c c) c)
Actual type: F (T2 (T2 c c) c) Bool
In the first argument of `goo4', namely `(goo3 False undefined)'
In the expression: goo4 (goo3 False undefined)
In an equation for `test4': test4 = goo4 (goo3 False undefined)
FrozenErrorTests.hs:52:15:
Occurs check: cannot construct the infinite type: c = T2 (T2 c c) c
Expected type: T2 (M (T2 (T2 c c) c)) (T2 (T2 c c) c)
Actual type: F (T2 (T2 c c) c) Bool
In the first argument of `goo4', namely `(goo3 False undefined)'
In the expression: goo4 (goo3 False undefined)
In an equation for `test4': test4 = goo4 (goo3 False undefined)
FrozenErrorTests.hs:52:15:
Couldn't match type `T2 c' with `M'
Expected type: T2 (M (T2 (T2 c c) c)) (T2 (T2 c c) c)
Actual type: F (T2 (T2 c c) c) Bool
In the first argument of `goo4', namely `(goo3 False undefined)'
In the expression: goo4 (goo3 False undefined)
In an equation for `test4': test4 = goo4 (goo3 False undefined)
FrozenErrorTests.hs:53:9:
Couldn't match type `T2 c c' with `M (T2 (T2 c c) c)'
Expected type: T2 (M (T2 (T2 c c) c)) (T2 (T2 c c) c)
Actual type: F (T2 (T2 c c) c) Bool
In the expression: goo3 False (goo4 undefined)
In an equation for `test5': test5 = goo3 False (goo4 undefined)
FrozenErrorTests.hs:53:9:
Occurs check: cannot construct the infinite type: c = T2 (T2 c c) c
Expected type: T2 (M (T2 (T2 c c) c)) (T2 (T2 c c) c)
Actual type: F (T2 (T2 c c) c) Bool
In the expression: goo3 False (goo4 undefined)
In an equation for `test5': test5 = goo3 False (goo4 undefined)
testsuite/tests/ghc-regress/typecheck/should_fail/all.T
View file @
be72302b
...
...
@@ -228,3 +228,4 @@ test('IPFail', normal, compile_fail, [''])
test
('
T3468
',
extra_clean
(['
T3468.hi-boot
']),
multimod_compile_fail
,
['
T3468
',
'
-v0
'])
test
('
T2846b
',
normal
,
compile_fail
,
[''])
test
('
FrozenErrorTests
',
normal
,
compile_fail
,
[''])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment