unsafe causes bug, news @ 11
I know there has been plenty of levity here lately but here goes :)
I didn't expect ‘isUndefined’ to be safe but this may be interesting to the devs (I am obedient and report it thusly and hereby-ly per GHC's request)
% ghci -ignore-dot-ghci
GHCi, version 8.1.20160117: http://www.haskell.org/ghc/ :? for help
Prelude> import Control.Exception
Prelude Control.Exception> import System.IO.Unsafe
Prelude Control.Exception System.IO.Unsafe> import Unsafe.Coerce
Prelude Control.Exception System.IO.Unsafe Unsafe.Coerce> isUndefined x = unsafePerformIO $ catch ((unsafeCoerce x :: IO ()) >> return False) (const $ return True :: SomeException -> IO Bool)
Prelude Control.Exception System.IO.Unsafe Unsafe.Coerce> isUndefined (succ True)
True
Prelude Control.Exception System.IO.Unsafe Unsafe.Coerce> isUndefined (succ False)
<interactive>: internal error: stg_ap_v_ret
(GHC version 8.1.20160117 for x86_64_unknown_linux)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
Aborted (core dumped)
%
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |