blob: 835e618b79e2cb65359650dcbce96fb8f805c3ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
{-# LANGUAGE ScopedTypeVariables #-}
-- Test Trac #246
module Main where
import Control.Exception
data T = T { x :: Bool, y :: Bool }
f (T { y=True, x=True }) = "Odd"
f _ = "OK"
g (T { x=True, y=True }) = "Odd2"
g _ = "Odd3"
funny = T { x = undefined, y = False }
main = do { print (f funny) -- Should work, because we test
-- y first, which fails, and falls
-- through to "OK"
; Control.Exception.catch
(print (g funny)) -- Should fail, because we test
(\(_::SomeException) -> print "caught") -- x first, and hit "undefined"
}
|