summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_run/CgStaticPointers.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/codeGen/should_run/CgStaticPointers.hs')
-rw-r--r--testsuite/tests/codeGen/should_run/CgStaticPointers.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/CgStaticPointers.hs b/testsuite/tests/codeGen/should_run/CgStaticPointers.hs
new file mode 100644
index 0000000000..bc11f4b076
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/CgStaticPointers.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE StaticPointers #-}
+
+-- |A test to load symbols produced by the static form.
+--
+-- First we have this program load itself using the GHC API.
+-- Then we look for the symbols that the static form should have
+-- exposed and use the values found at the symbol addresses.
+--
+module Main(main) where
+
+import Data.Typeable
+import GHC.StaticPtr
+
+main :: IO ()
+main = do
+ -- For some reason, removing the type signature below causes @g@ to appear
+ -- in the desugarer with a coercion like:
+ -- main@main:Main.g{v r20J} |> (Sub cobox_a36d{v}[lid])
+ print $ deRefStaticPtr (static g :: StaticPtr String)
+ -- For some reason, removing the type signature below causes an assertion
+ -- failure in the compiler:
+ --
+ -- ASSERT failed! file compiler/typecheck/TcType.lhs line 645
+ print $ deRefStaticPtr (static t_field :: StaticPtr (T Char -> Char)) $ T 'b'
+
+g :: String
+g = "found"
+
+data T a = T { t_field :: a }
+ deriving Typeable