Give raise# a return type of open kind (#10481)
authorReid Barton <rwbarton@gmail.com>
Fri, 31 Jul 2015 21:09:45 +0000 (17:09 -0400)
committerReid Barton <rwbarton@gmail.com>
Fri, 31 Jul 2015 21:09:46 +0000 (17:09 -0400)
Test Plan: validate

Reviewers: austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, thomie

Differential Revision: https://phabricator.haskell.org/D1116

GHC Trac Issues: #10481

compiler/prelude/primops.txt.pp
testsuite/.gitignore
testsuite/tests/primops/should_run/T10481.hs [new file with mode: 0644]
testsuite/tests/primops/should_run/T10481.stderr [new file with mode: 0644]
testsuite/tests/primops/should_run/all.T

index 9b107f2..6d45ed9 100644 (file)
@@ -1960,7 +1960,8 @@ primop  CatchOp "catch#" GenPrimOp
    has_side_effects = True
 
 primop  RaiseOp "raise#" GenPrimOp
-   a -> b
+   b -> o
+      -- NB: the type variable "o" is "a", but with OpenKind
    with
    strictness  = { \ _arity -> mkClosedStrictSig [topDmd] botRes }
       -- NB: result is bottom
index 6ebb05a..c92ce71 100644 (file)
@@ -1221,6 +1221,7 @@ mk/ghcconfig*_bin_ghc-*.exe.mk
 /tests/polykinds/PolyKinds10
 /tests/primops/should_run/T6135
 /tests/primops/should_run/T7689
+/tests/primops/should_run/T10481
 /tests/profiling/should_compile/prof001
 /tests/profiling/should_compile/prof002
 /tests/profiling/should_run/2592
diff --git a/testsuite/tests/primops/should_run/T10481.hs b/testsuite/tests/primops/should_run/T10481.hs
new file mode 100644 (file)
index 0000000..bfdb356
--- /dev/null
@@ -0,0 +1,9 @@
+{-# LANGUAGE MagicHash #-}
+
+import GHC.Exts
+import Control.Exception
+
+f :: ArithException -> Int#
+f x = raise# (toException x)
+
+main = print (I# (f Overflow))
diff --git a/testsuite/tests/primops/should_run/T10481.stderr b/testsuite/tests/primops/should_run/T10481.stderr
new file mode 100644 (file)
index 0000000..228377e
--- /dev/null
@@ -0,0 +1 @@
+T10481: arithmetic overflow
index 12f9491..b21279a 100644 (file)
@@ -2,3 +2,4 @@ test('T6135', normal, compile_and_run, [''])
 test('T7689', normal, compile_and_run, [''])
 # The test is using unboxed tuples, so omit ghci
 test('T9430', omit_ways(['ghci']), compile_and_run, [''])
+test('T10481', exit_code(1), compile_and_run, [''])