[GHC] #13380: raiseIO# result looks wrong

GHC ghc-devs at haskell.org
Mon Mar 6 01:14:32 UTC 2017


#13380: raiseIO# result looks wrong
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.2.1
       Component:  Compiler          |              Version:  8.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Other             |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by rwbarton):

 I think it's just a bit of imprecise wording. It's right that `raiseIO#`
 returns bottom after being applied to ''two'' arguments, as:
 {{{#!hs
 raiseIO# :: a -> State# RealWorld -> (# State# RealWorld, b #)
 }}}
 But the function in the example is strict in `y` only after being applied
 to a third argument, i.e., executed. You can try this:
 {{{#!hs
 import Control.Exception

 f :: Int -> Int -> IO Int
 f x y | x > 0 = throwIO StackOverflow
       | y > 0 = return 1
       | otherwise = return 2

 u :: Int
 u = -1
 {-# NOINLINE u #-}

 main :: IO ()
 main = f u undefined `seq` return ()
 }}}
 and it's not optimized to bottom.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13380#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list