summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_run/T21141.hs
blob: f972eca4774b3a38c39c72552ce1fc91b0a27dd3 (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
26
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE LambdaCase #-}

module Main where

import GHC.Prim.Exception
import GHC.Exception.Type
import Control.Exception
import System.Mem

main ::IO ()
main = do
  -- evaluate the CAF
  evaluate raiseUnderflow
    `catch` \case
      Underflow -> pure ()
      e         -> putStrLn "Unexpected exception"

  -- free it with buggy compiler
  performGC

  -- reuse it
  evaluate raiseUnderflow
    `catch` \case
      Underflow -> pure ()
      e         -> putStrLn "Unexpected exception"