From a77b9ec2a6153065565bca7bb154fff35b830b82 Mon Sep 17 00:00:00 2001 From: Krzysztof Gogolewski Date: Sun, 23 Aug 2020 20:35:52 +0200 Subject: Add a test for #18397 The bug was fixed by !3421. --- testsuite/tests/codeGen/should_compile/T18397.hs | 20 ++++++++++++++++++++ testsuite/tests/codeGen/should_compile/all.T | 4 ++++ 2 files changed, 24 insertions(+) create mode 100644 testsuite/tests/codeGen/should_compile/T18397.hs (limited to 'testsuite') diff --git a/testsuite/tests/codeGen/should_compile/T18397.hs b/testsuite/tests/codeGen/should_compile/T18397.hs new file mode 100644 index 0000000000..6941b811ba --- /dev/null +++ b/testsuite/tests/codeGen/should_compile/T18397.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE UnboxedTuples #-} +module T18397 where + +import GHC.Exts +import GHC.ST + +data MutableArray s a = MutableArray (MutableArray# s a) + +runArray# + :: (forall s. ST s (MutableArray s a)) + -> Array# a +runArray# m = case runRW# $ \s -> + case unST m s of { (# s', MutableArray mary# #) -> + unsafeFreezeArray# mary# s'} of (# _, ary# #) -> ary# + +unST :: ST s a -> State# s -> (# State# s, a #) +unST (ST f) = f + diff --git a/testsuite/tests/codeGen/should_compile/all.T b/testsuite/tests/codeGen/should_compile/all.T index 4e0a25b7d5..cb61b2b44c 100644 --- a/testsuite/tests/codeGen/should_compile/all.T +++ b/testsuite/tests/codeGen/should_compile/all.T @@ -91,7 +91,11 @@ test('T17648', normal, makefile_test, []) test('T17904', normal, compile, ['-O']) test('T18227A', normal, compile, ['']) test('T18227B', normal, compile, ['']) + +# runRW#-related test('T18291', normal, compile, ['-O0']) +test('T18397', normal, compile, ['-O0']) + test('T15570', when(unregisterised(), skip), compile, ['-Wno-overflowed-literals']) -- cgit v1.2.1