diff options
Diffstat (limited to 'testsuite/tests')
14 files changed, 117 insertions, 7 deletions
diff --git a/testsuite/tests/overloadedrecflds/should_compile/T11173.hs b/testsuite/tests/overloadedrecflds/should_compile/T11173.hs new file mode 100644 index 0000000000..54b363869e --- /dev/null +++ b/testsuite/tests/overloadedrecflds/should_compile/T11173.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE DuplicateRecordFields #-} +module T11173 where +import T11173a (A(..)) + +-- Check that the fixity declaration applied to the field 'foo' is used +x b = b `foo` b `foo` 0 diff --git a/testsuite/tests/overloadedrecflds/should_compile/T11173a.hs b/testsuite/tests/overloadedrecflds/should_compile/T11173a.hs new file mode 100644 index 0000000000..ae8c37f763 --- /dev/null +++ b/testsuite/tests/overloadedrecflds/should_compile/T11173a.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE DuplicateRecordFields #-} +module T11173a where + +data A = A { foo :: Int -> Int, bar :: Int -> Int } +newtype B = B { foo :: Int -> Int } +infixr 5 `foo` +infixr 5 `bar` + +-- This is well-typed only if the fixity is correctly applied +y b = b `bar` b `bar` 0 diff --git a/testsuite/tests/overloadedrecflds/should_compile/all.T b/testsuite/tests/overloadedrecflds/should_compile/all.T new file mode 100644 index 0000000000..ea5baf899e --- /dev/null +++ b/testsuite/tests/overloadedrecflds/should_compile/all.T @@ -0,0 +1 @@ +test('T11173', extra_clean(['T11173a.hi', 'T11173a.o']), multimod_compile, ['T11173', '-v0']) diff --git a/testsuite/tests/overloadedrecflds/should_fail/OverloadedRecFldsFail11_A.hs b/testsuite/tests/overloadedrecflds/should_fail/OverloadedRecFldsFail11_A.hs new file mode 100644 index 0000000000..9dbadc648c --- /dev/null +++ b/testsuite/tests/overloadedrecflds/should_fail/OverloadedRecFldsFail11_A.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE DuplicateRecordFields #-} +module OverloadedRecFldsFail11_A where + +{-# WARNING foo "Warning on a record field" #-} +data S = MkS { foo :: Bool } +data T = MkT { foo :: Int } diff --git a/testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity.hs b/testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity.hs new file mode 100644 index 0000000000..d4dd38edbb --- /dev/null +++ b/testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE DuplicateRecordFields #-} +module T11167_ambiguous_fixity where +import T11167_ambiguous_fixity_A +import T11167_ambiguous_fixity_B + +x a = (a :: A) `foo` 0 diff --git a/testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity.stderr b/testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity.stderr new file mode 100644 index 0000000000..26b8daa53d --- /dev/null +++ b/testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity.stderr @@ -0,0 +1,16 @@ +[1 of 3] Compiling T11167_ambiguous_fixity_B ( T11167_ambiguous_fixity_B.hs, T11167_ambiguous_fixity_B.o ) +[2 of 3] Compiling T11167_ambiguous_fixity_A ( T11167_ambiguous_fixity_A.hs, T11167_ambiguous_fixity_A.o ) +[3 of 3] Compiling T11167_ambiguous_fixity ( T11167_ambiguous_fixity.hs, T11167_ambiguous_fixity.o ) + +T11167_ambiguous_fixity.hs:6:7: error: + Ambiguous fixity for record field ‘foo’ + Conflicts: + infixr 3 + imported from ‘T11167_ambiguous_fixity_A’ at T11167_ambiguous_fixity.hs:3:1-32 + (and originally defined at T11167_ambiguous_fixity_A.hs:4:16-18) + infixr 3 + imported from ‘T11167_ambiguous_fixity_A’ at T11167_ambiguous_fixity.hs:3:1-32 + (and originally defined at T11167_ambiguous_fixity_A.hs:3:16-18) + infixl 5 + imported from ‘T11167_ambiguous_fixity_B’ at T11167_ambiguous_fixity.hs:4:1-32 + (and originally defined at T11167_ambiguous_fixity_B.hs:2:16-18) diff --git a/testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity_A.hs b/testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity_A.hs new file mode 100644 index 0000000000..cc5440de16 --- /dev/null +++ b/testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity_A.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE DuplicateRecordFields #-} +module T11167_ambiguous_fixity_A where +data A = MkA { foo :: Int -> Int } +data C = MkC { foo :: Int -> Int } +infixr 3 `foo` diff --git a/testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity_B.hs b/testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity_B.hs new file mode 100644 index 0000000000..927a336537 --- /dev/null +++ b/testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity_B.hs @@ -0,0 +1,3 @@ +module T11167_ambiguous_fixity_B where +data B = MkB { foo :: Int -> Int } +infixl 5 `foo` diff --git a/testsuite/tests/overloadedrecflds/should_fail/all.T b/testsuite/tests/overloadedrecflds/should_fail/all.T index a9c7426c78..a1b8ccb4ad 100644 --- a/testsuite/tests/overloadedrecflds/should_fail/all.T +++ b/testsuite/tests/overloadedrecflds/should_fail/all.T @@ -16,10 +16,16 @@ test('overloadedrecfldsfail10', , 'OverloadedRecFldsFail10_B.hi', 'OverloadedRecFldsFail10_B.o' , 'OverloadedRecFldsFail10_C.hi', 'OverloadedRecFldsFail10_C.o']), multimod_compile_fail, ['overloadedrecfldsfail10', '']) -test('overloadedrecfldsfail11', normal, compile_fail, ['']) +test('overloadedrecfldsfail11', + extra_clean(['OverloadedRecFldsFail11_A.hi', 'OverloadedRecFldsFail11_A.o']), + multimod_compile_fail, ['overloadedrecfldsfail11', '']) test('overloadedrecfldsfail12', extra_clean(['OverloadedRecFldsFail12_A.hi', 'OverloadedRecFldsFail12_A.o']), multimod_compile_fail, ['overloadedrecfldsfail12', '']) test('overloadedrecfldsfail13', normal, compile_fail, ['']) test('overloadedrecfldsfail14', normal, compile_fail, ['']) test('overloadedlabelsfail01', normal, compile_fail, ['']) +test('T11167_ambiguous_fixity', + extra_clean([ 'T11167_ambiguous_fixity_A.hi', 'T11167_ambiguous_fixity_A.o' + , 'T11167_ambiguous_fixity_B.hi', 'T11167_ambiguous_fixity_B.o' ]), + multimod_compile_fail, ['T11167_ambiguous_fixity', '']) diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.hs b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.hs index 9c5c145c94..c1c309a48a 100644 --- a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.hs +++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.hs @@ -1,5 +1,5 @@ {-# LANGUAGE DuplicateRecordFields #-} +{-# OPTIONS_GHC -Werror #-} +import OverloadedRecFldsFail11_A -{-# WARNING foo "No warnings for DRFs" #-} -data S = MkS { foo :: Bool } -data T = MkT { foo :: Int } +main = print (foo (MkS True :: S)) diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr index 650456ccd0..771a46f10c 100644 --- a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr +++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr @@ -1,4 +1,9 @@ +[1 of 2] Compiling OverloadedRecFldsFail11_A ( OverloadedRecFldsFail11_A.hs, OverloadedRecFldsFail11_A.o ) +[2 of 2] Compiling Main ( overloadedrecfldsfail11.hs, overloadedrecfldsfail11.o ) -overloadedrecfldsfail11.hs:3:13: error: - The deprecation for ‘foo’ lacks an accompanying binding - (The deprecation must be given where ‘foo’ is declared) +overloadedrecfldsfail11.hs:5:15: warning: + In the use of ‘foo’ (imported from OverloadedRecFldsFail11_A): + "Warning on a record field" + +<no location info>: error: +Failing due to -Werror. diff --git a/testsuite/tests/rename/should_compile/T11167.hs b/testsuite/tests/rename/should_compile/T11167.hs new file mode 100644 index 0000000000..644cc90bed --- /dev/null +++ b/testsuite/tests/rename/should_compile/T11167.hs @@ -0,0 +1,21 @@ +module T11167 where + +data SomeException + +newtype ContT r m a = ContT {runContT :: (a -> m r) -> m r} + +runContT' :: ContT r m a -> (a -> m r) -> m r +runContT' = runContT + +catch_ :: IO a -> (SomeException -> IO a) -> IO a +catch_ = undefined + +foo :: IO () +foo = (undefined :: ContT () IO a) + `runContT` (undefined :: a -> IO ()) + `catch_` (undefined :: SomeException -> IO ()) + +foo' :: IO () +foo' = (undefined :: ContT () IO a) + `runContT'` (undefined :: a -> IO ()) + `catch_` (undefined :: SomeException -> IO ()) diff --git a/testsuite/tests/rename/should_compile/T11167_ambig.hs b/testsuite/tests/rename/should_compile/T11167_ambig.hs new file mode 100644 index 0000000000..74df05e5ee --- /dev/null +++ b/testsuite/tests/rename/should_compile/T11167_ambig.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE DuplicateRecordFields #-} +module T11167_ambig where + +data SomeException + +newtype ContT r m a = ContT {runContT :: (a -> m r) -> m r} +newtype ContT' r m a = ContT' {runContT :: (a -> m r) -> m r} + +runContT' :: ContT r m a -> (a -> m r) -> m r +runContT' = runContT + +catch_ :: IO a -> (SomeException -> IO a) -> IO a +catch_ = undefined + +foo :: IO () +foo = (undefined :: ContT () IO a) + `runContT` (undefined :: a -> IO ()) + `catch_` (undefined :: SomeException -> IO ()) + +foo' :: IO () +foo' = (undefined :: ContT () IO a) + `runContT'` (undefined :: a -> IO ()) + `catch_` (undefined :: SomeException -> IO ()) diff --git a/testsuite/tests/rename/should_compile/all.T b/testsuite/tests/rename/should_compile/all.T index 05bc2507d0..8c120cd4c2 100644 --- a/testsuite/tests/rename/should_compile/all.T +++ b/testsuite/tests/rename/should_compile/all.T @@ -230,3 +230,5 @@ test('T11164', extra_clean(['T11164a.hi', 'T11164a.o', 'T11164b.hi', 'T11164b.o']), multimod_compile, ['T11164', '-v0']) +test('T11167', normal, compile, ['']) +test('T11167_ambig', normal, compile, ['']) |