Allow unlifted types in pattern synonym result type
authorMatthew Pickering <matthewtpickering@gmail.com>
Sun, 22 May 2016 10:52:26 +0000 (11:52 +0100)
committerMatthew Pickering <matthewtpickering@gmail.com>
Mon, 23 May 2016 12:23:00 +0000 (13:23 +0100)
Fixes #12094

Test Plan: ./validate

Reviewers: austin, bgamari

Subscribers: thomie

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

GHC Trac Issues: #12094

compiler/typecheck/TcPatSyn.hs
testsuite/tests/patsyn/should_compile/T12094.hs [new file with mode: 0644]
testsuite/tests/patsyn/should_compile/all.T

index 8c577cf..8763774 100644 (file)
@@ -113,7 +113,9 @@ tcPatSynSig name sig_ty
               do { req     <- tcHsContext hs_req
                  ; prov    <- tcHsContext hs_prov
                  ; arg_tys <- mapM tcHsOpenType (hs_arg_tys :: [LHsType Name])
-                 ; body_ty <- tcHsLiftedType hs_body_ty
+                 -- A (literal) pattern can be unlifted;
+                 -- -- e.g. pattern Zero <- 0#   (Trac #12094)
+                 ; body_ty <- tcHsOpenType hs_body_ty
                  ; let bound_tvs
                          = unionVarSets [ allBoundVariabless req
                                         , allBoundVariabless prov
diff --git a/testsuite/tests/patsyn/should_compile/T12094.hs b/testsuite/tests/patsyn/should_compile/T12094.hs
new file mode 100644 (file)
index 0000000..5b4e6b4
--- /dev/null
@@ -0,0 +1,8 @@
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE PatternSynonyms #-}
+module T12094 where
+
+import GHC.Exts (Int#)
+
+pattern Zero :: Int# -- commenting out this line works
+pattern Zero <- 0#
index d2f6809..035cd00 100644 (file)
@@ -52,4 +52,5 @@ test('T11336', normal, compile, [''])
 test('T11367', normal, compile, [''])
 test('T11351', normal, compile, [''])
 test('T11633', normal, compile, [''])
-test('T11959', expect_broken(11959), multimod_compile, ['T11959', '-v0'])
\ No newline at end of file
+test('T11959', expect_broken(11959), multimod_compile, ['T11959', '-v0'])
+test('T12094', normal, compile, [''])