diff options
Diffstat (limited to 'testsuite/tests/typecheck/should_fail')
6 files changed, 85 insertions, 7 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T21158.hs b/testsuite/tests/typecheck/should_fail/T21158.hs new file mode 100644 index 0000000000..282989f5b8 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T21158.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE TypeFamilies #-} +module T21158 where + +type family F a + +data T b = MkT { x :: [Int], y :: [F b] } + +emptyT :: T b +emptyT = MkT [] [] + +foo1 :: [Int] -> T b +foo1 newx = emptyT { x = newx } + +foo2 :: [Int] -> T b +foo2 newx = case emptyT of MkT x y -> MkT newx y diff --git a/testsuite/tests/typecheck/should_fail/T21158.stderr b/testsuite/tests/typecheck/should_fail/T21158.stderr new file mode 100644 index 0000000000..88394ad2e9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T21158.stderr @@ -0,0 +1,29 @@ + +T21158.hs:12:14: error: + • Couldn't match type: F b0 + with: F b + Expected: [F b] + Actual: [F b0] + NB: ‘F’ is a non-injective type family + The type variable ‘b0’ is ambiguous + • In a record update at field ‘x’, + with type constructor ‘T’ + and data constructor ‘MkT’. + In the expression: emptyT {x = newx} + In an equation for ‘foo1’: foo1 newx = emptyT {x = newx} + • Relevant bindings include + foo1 :: [Int] -> T b (bound at T21158.hs:12:1) + +T21158.hs:15:49: error: + • Couldn't match type: F b1 + with: F b + Expected: [F b] + Actual: [F b1] + NB: ‘F’ is a non-injective type family + The type variable ‘b1’ is ambiguous + • In the second argument of ‘MkT’, namely ‘y’ + In the expression: MkT newx y + In a case alternative: MkT x y -> MkT newx y + • Relevant bindings include + y :: [F b1] (bound at T21158.hs:15:35) + foo2 :: [Int] -> T b (bound at T21158.hs:15:1) diff --git a/testsuite/tests/typecheck/should_fail/T3323.stderr b/testsuite/tests/typecheck/should_fail/T3323.stderr index 2f8344bb4e..1e77e05318 100644 --- a/testsuite/tests/typecheck/should_fail/T3323.stderr +++ b/testsuite/tests/typecheck/should_fail/T3323.stderr @@ -1,5 +1,34 @@ -T3323.hs:18:7: - Record update for insufficiently polymorphic field: haDevice :: dev - In the expression: h {haDevice = undefined} - In an equation for ‘f’: f h = h {haDevice = undefined} +T3323.hs:18:7: error: + • Could not deduce (GHC.IO.Device.RawIO dev0) + from the context: (GHC.IO.Device.RawIO dev, + GHC.IO.Device.IODevice dev, GHC.IO.BufferedIO.BufferedIO dev, + base-4.16.0.0:Data.Typeable.Internal.Typeable dev) + bound by a pattern with constructor: + Handle__ :: forall dev enc_state dec_state. + (GHC.IO.Device.RawIO dev, GHC.IO.Device.IODevice dev, + GHC.IO.BufferedIO.BufferedIO dev, + base-4.16.0.0:Data.Typeable.Internal.Typeable dev) => + dev + -> HandleType + -> GHC.IORef.IORef (GHC.IO.Buffer.Buffer GHC.Word.Word8) + -> BufferMode + -> GHC.IORef.IORef (dec_state, GHC.IO.Buffer.Buffer GHC.Word.Word8) + -> GHC.IORef.IORef (GHC.IO.Buffer.Buffer GHC.IO.Buffer.CharBufElem) + -> GHC.IORef.IORef (BufferList GHC.IO.Buffer.CharBufElem) + -> Maybe (GHC.IO.Encoding.Types.TextEncoder enc_state) + -> Maybe (GHC.IO.Encoding.Types.TextDecoder dec_state) + -> Maybe GHC.IO.Encoding.Types.TextEncoding + -> Newline + -> Newline + -> Maybe (GHC.MVar.MVar Handle__) + -> Handle__, + in a case alternative + at T3323.hs:18:7-28 + The type variable ‘dev0’ is ambiguous + • In a record update at field ‘haDevice’, + with type constructor ‘Handle__’, + data constructor ‘Handle__’ + and existential variables ‘dev’, ‘enc_state’, ‘dec_state’. + In the expression: h {haDevice = undefined} + In an equation for ‘f’: f h = h {haDevice = undefined} diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index aceaf051c9..83ba2c4414 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -655,3 +655,4 @@ test('T20768_fail', normal, compile_fail, ['']) test('T21327', normal, compile_fail, ['']) test('T21328', normal, compile_fail, ['']) test('T21338', normal, compile_fail, ['']) +test('T21158', normal, compile_fail, ['']) diff --git a/testsuite/tests/typecheck/should_fail/tcfail102.stderr b/testsuite/tests/typecheck/should_fail/tcfail102.stderr index fdfedf7ebb..88b01eea0c 100644 --- a/testsuite/tests/typecheck/should_fail/tcfail102.stderr +++ b/testsuite/tests/typecheck/should_fail/tcfail102.stderr @@ -4,10 +4,12 @@ tcfail102.hs:1:14: warning: [-Wdeprecated-flags (in -Wdefault)] tcfail102.hs:9:7: error: • Could not deduce (Integral (Ratio a)) - arising from a record update from the context: Integral a bound by the type signature for: f :: forall a. Integral a => P (Ratio a) -> P (Ratio a) at tcfail102.hs:8:1-45 - • In the expression: x {p = p x} + • In a record update at field ‘p’, + with type constructor ‘P’ + and data constructor ‘P’. + In the expression: x {p = p x} In an equation for ‘f’: f x = x {p = p x} diff --git a/testsuite/tests/typecheck/should_fail/tcfail181.stderr b/testsuite/tests/typecheck/should_fail/tcfail181.stderr index 887c65f574..fdb16ea140 100644 --- a/testsuite/tests/typecheck/should_fail/tcfail181.stderr +++ b/testsuite/tests/typecheck/should_fail/tcfail181.stderr @@ -13,5 +13,7 @@ tcfail181.hs:17:9: error: ...plus one instance involving out-of-scope types (use -fprint-potential-instances to see them all) • In the expression: foo + In a record update at field ‘bar’, + with type constructor ‘Something’ + and data constructor ‘Something’. In the expression: foo {bar = return True} - In an equation for ‘wog’: wog x = foo {bar = return True} |