From a446bde622b9e14b0eb7aa2821b093a17b5d33d1 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Sat, 4 Mar 2023 22:37:43 +0000 Subject: Add regression test for #22328 --- testsuite/tests/patsyn/should_compile/T22328.hs | 16 ++++++++++++++++ testsuite/tests/patsyn/should_compile/all.T | 1 + 2 files changed, 17 insertions(+) create mode 100644 testsuite/tests/patsyn/should_compile/T22328.hs diff --git a/testsuite/tests/patsyn/should_compile/T22328.hs b/testsuite/tests/patsyn/should_compile/T22328.hs new file mode 100644 index 0000000000..02830b8290 --- /dev/null +++ b/testsuite/tests/patsyn/should_compile/T22328.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE TypeApplications, PatternSynonyms, GADTs, ViewPatterns #-} + +module T22328 where + +import Data.Typeable + +data Gadt x y where + ExistentialInGadt :: Typeable a => a -> Gadt x x + +pattern CastGadt :: Typeable a => x ~ y => a -> Gadt x y +pattern CastGadt a <- ExistentialInGadt (cast -> Just a) + +test :: Gadt i o -> Bool +test gadt = case gadt of + CastGadt @Bool a -> a + _ -> False diff --git a/testsuite/tests/patsyn/should_compile/all.T b/testsuite/tests/patsyn/should_compile/all.T index 3a5b3aef5a..d90a0e3358 100644 --- a/testsuite/tests/patsyn/should_compile/all.T +++ b/testsuite/tests/patsyn/should_compile/all.T @@ -84,3 +84,4 @@ test('T14630', normal, compile, ['-Wname-shadowing']) test('T21531', [ grep_errmsg(r'INLINE') ], compile, ['-ddump-ds']) test('T22521', normal, compile, ['']) test('T23038', normal, compile_fail, ['']) +test('T22328', normal, compile, ['']) -- cgit v1.2.1