summaryrefslogtreecommitdiff
path: root/testsuite/tests/deSugar/should_run/T246.hs
blob: 2845db3ab079ed6683373a4bb09eeb6af2bf36a5 (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 #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"
          }