From 7ec783de6ba9e380da6737dad78d9a82cf56002a Mon Sep 17 00:00:00 2001
From: Matthew Pickering <matthewtpickering@gmail.com>
Date: Wed, 5 Jan 2022 11:04:53 +0000
Subject: [PATCH] Add test for using type families with static pointers

Issue was reported on #13306
---
 .../should_compile/StaticPtrTypeFamily.hs       | 17 +++++++++++++++++
 testsuite/tests/typecheck/should_compile/all.T  |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 testsuite/tests/typecheck/should_compile/StaticPtrTypeFamily.hs

diff --git a/testsuite/tests/typecheck/should_compile/StaticPtrTypeFamily.hs b/testsuite/tests/typecheck/should_compile/StaticPtrTypeFamily.hs
new file mode 100644
index 000000000000..96a776ecec82
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/StaticPtrTypeFamily.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE FlexibleContexts    #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE StaticPointers      #-}
+{-# LANGUAGE TypeFamilies        #-}
+
+module StaticPtrTypeFamily where
+
+import Data.Typeable
+import GHC.StaticPtr
+
+type family F a
+
+caller :: forall a. (Typeable a, Typeable (F a)) => a -> F a -> ()
+caller a fa = deRefStaticPtr (static func) a fa
+
+func :: a -> F a -> ()
+func _ _ = ()
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index 8b31c8b3ccb8..4da7a858cb9d 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -804,6 +804,6 @@ test('T20584b', normal, compile, [''])
 test('T20588b', [extra_files(['T20588b.hs', 'T20588b.hs-boot', 'T20588b_aux.hs'])], multimod_compile, ['T20588b_aux.hs', '-v0'])
 test('T20588d', [extra_files(['T20588d.hs', 'T20588d.hs-boot', 'T20588d_aux.hs'])], multimod_compile, ['T20588d_aux.hs', '-v0'])
 test('T20661', [extra_files(['T20661.hs', 'T20661.hs-boot', 'T20661_aux.hs'])], multimod_compile, ['T20661_aux.hs', '-v0'])
-
 test('T20873', normal, compile, [''])
 test('T20873b', [extra_files(['T20873b_aux.hs'])], multimod_compile, ['T20873b', '-v0'])
+test('StaticPtrTypeFamily', normal, compile, [''])
-- 
GitLab