diff options
Diffstat (limited to 'testsuite/tests/typecheck')
-rw-r--r-- | testsuite/tests/typecheck/should_fail/T12406.hs | 20 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/T12406.stderr | 12 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/all.T | 3 |
3 files changed, 34 insertions, 1 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T12406.hs b/testsuite/tests/typecheck/should_fail/T12406.hs new file mode 100644 index 0000000000..20264cc51d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T12406.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE TypeFamilies #-} +{-# OPTIONS_GHC -fdefer-typed-holes #-} + +module T12406 where + +-- import Control.Monad -- comment this out to cause error +import Data.IORef + +class MonadRef m where + type Ref m :: * -> * + newRef :: a -> m (Ref m a) + readRef :: Ref m a -> m a + +instance MonadRef IO where + type Ref IO = IORef + newRef = newIORef + readRef = readIORef + +foo :: IO () +foo = newRef (pure ()) >>= join . readRef diff --git a/testsuite/tests/typecheck/should_fail/T12406.stderr b/testsuite/tests/typecheck/should_fail/T12406.stderr new file mode 100644 index 0000000000..85096e6184 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T12406.stderr @@ -0,0 +1,12 @@ + +T12406.hs:20:7: error: + • Couldn't match type ‘Ref m0’ with ‘IORef’ + Expected type: IO (Ref m0 (f0 ())) + Actual type: IO (Ref IO (f0 ())) + The type variable ‘m0’ is ambiguous + • In the first argument of ‘(>>=)’, namely ‘newRef (pure ())’ + In the expression: newRef (pure ()) >>= join . readRef + In an equation for ‘foo’: foo = newRef (pure ()) >>= join . readRef + +T12406.hs:20:28: error: + Variable not in scope: join :: m0 (f0 ()) -> IO () diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index acc3f9f8e9..b064c56a01 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -423,4 +423,5 @@ test('T12063', [ expect_broken(12063), extra_clean(['T12063.hi-boot', 'T12063.o- test('T11974b', normal, compile_fail, ['']) test('T12151', normal, compile_fail, ['']) test('T7437', normal, compile_fail, ['']) -test('T12177', normal, compile_fail, [''])
\ No newline at end of file +test('T12177', normal, compile_fail, ['']) +test('T12406', normal, compile_fail, ['']) |