From fefd4e312f0249117f2d5a5a6962edb1e0b6ed19 Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Mon, 21 Mar 2022 17:48:45 +0000 Subject: testsuite: Remove library dependenices from T21119 These dependencies would affect the demand signature depending on various rules and so on. Fixes #21271 --- testsuite/tests/stranal/sigs/T21119.hs | 31 ++++++++++++++++++++++++------ testsuite/tests/stranal/sigs/T21119.stderr | 26 ++++++++++++++++++------- testsuite/tests/stranal/sigs/all.T | 1 + 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/testsuite/tests/stranal/sigs/T21119.hs b/testsuite/tests/stranal/sigs/T21119.hs index 7be2cf1788..8bebcf5b16 100644 --- a/testsuite/tests/stranal/sigs/T21119.hs +++ b/testsuite/tests/stranal/sigs/T21119.hs @@ -3,12 +3,31 @@ -- {-# LANGUAGE PatternSynonyms #-} -- {-# LANGUAGE BangPatterns #-} -- {-# LANGUAGE MagicHash, UnboxedTuples #-} -module T21119 where +{-# LANGUAGE MagicHash #-} +module T21119 ( get, getIO, indexError, throwIndexError ) where -import Control.Exception +import Control.Exception (Exception(..)) +import GHC.IO hiding (throwIO) +import GHC.Exts -indexError :: Show a => (a, a) -> a -> String -> b -indexError rng i s = error (show rng ++ show i ++ show s) +throwIO :: Exception e => e -> IO a +throwIO e = IO (raiseIO# (toException e)) + +myconcat :: [[a]] -> [a] +myconcat = concat +{-# NOINLINE myconcat #-} + +class MyShow a where + myshow :: a -> String + +instance MyShow Int where + myshow !_ = "0" + +instance MyShow (a, b) where + myshow !_ = "()" + +indexError :: MyShow a => (a, a) -> a -> String -> b +indexError rng i s = errorWithoutStackTrace (myconcat [myshow rng, myshow i, s]) get :: (Int, Int) -> Int -> [a] -> a get p@(l,u) i xs @@ -17,8 +36,8 @@ get p@(l,u) i xs -- Now the same with precise exceptions: -throwIndexError :: Show a => (a, a) -> a -> String -> IO b -throwIndexError rng i s = throwIO (userError (show rng ++ show i ++ show s)) +throwIndexError :: MyShow a => (a, a) -> a -> String -> IO b +throwIndexError rng i s = throwIO (userError (myconcat [myshow rng, myshow i, s])) -- It's important that we don't unbox 'u' here. -- We may or may not unbox 'p' and 'l'. diff --git a/testsuite/tests/stranal/sigs/T21119.stderr b/testsuite/tests/stranal/sigs/T21119.stderr index dfefcdea03..0a398888d0 100644 --- a/testsuite/tests/stranal/sigs/T21119.stderr +++ b/testsuite/tests/stranal/sigs/T21119.stderr @@ -1,14 +1,22 @@ ==================== Strictness signatures ==================== +T21119.$fMyShow(,): <1!A> +T21119.$fMyShowInt: <1!A> +T21119.$tc'C:MyShow: +T21119.$tcMyShow: T21119.$trModule: -T21119.get: <1!P(S!P(L),S!P(L))><1!P(L)><1L> -T21119.getIO: <1P(SL,L)><1L> -T21119.indexError: <1!S><1!S>b -T21119.throwIndexError: x +T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> +T21119.getIO: <1P(1L,ML)><1L> +T21119.indexError: <1C1(L)><1!B>b +T21119.throwIndexError: x ==================== Cpr signatures ==================== +T21119.$fMyShow(,): +T21119.$fMyShowInt: +T21119.$tc'C:MyShow: +T21119.$tcMyShow: T21119.$trModule: T21119.get: T21119.getIO: 1 @@ -18,10 +26,14 @@ T21119.throwIndexError: b ==================== Strictness signatures ==================== +T21119.$fMyShow(,): <1!A> +T21119.$fMyShowInt: <1!A> +T21119.$tc'C:MyShow: +T21119.$tcMyShow: T21119.$trModule: T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> -T21119.getIO: <1P(SL,L)><1L> -T21119.indexError: <1P(SCS(C1(L)),1C1(L),B)><1!S><1!S>b -T21119.throwIndexError: x +T21119.getIO: <1P(1L,ML)><1L> +T21119.indexError: <1C1(L)><1!B>b +T21119.throwIndexError: x diff --git a/testsuite/tests/stranal/sigs/all.T b/testsuite/tests/stranal/sigs/all.T index 59a4891f6d..876d2242d8 100644 --- a/testsuite/tests/stranal/sigs/all.T +++ b/testsuite/tests/stranal/sigs/all.T @@ -31,4 +31,5 @@ test('T18907', normal, compile, ['']) test('T13331', normal, compile, ['']) test('T20746', normal, compile, ['']) test('T20746b', normal, compile, ['']) + test('T21119', normal, compile, ['']) -- cgit v1.2.1