summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail/T21158.stderr
diff options
context:
space:
mode:
authorCarrieMY <carrie.xmy@gmail.com>2022-05-25 16:43:03 +0200
committersheaf <sam.derbyshire@gmail.com>2022-05-25 16:43:03 +0200
commite74fc066cb33e5b7ae0d37cedb30230c597ef1ce (patch)
treecc17cbbe235ada53bdac93e06cbfe4ca632ffa4a /testsuite/tests/typecheck/should_fail/T21158.stderr
parent2ff18e390b119c611b3dd429b76cfcbf36ef9545 (diff)
downloadhaskell-e74fc066cb33e5b7ae0d37cedb30230c597ef1ce.tar.gz
Desugar RecordUpd in `tcExpr`wip/T18802
This patch typechecks record updates by desugaring them inside the typechecker using the HsExpansion mechanism, and then typechecking this desugared result. Example: data T p q = T1 { x :: Int, y :: Bool, z :: Char } | T2 { v :: Char } | T3 { x :: Int } | T4 { p :: Float, y :: Bool, x :: Int } | T5 The record update `e { x=e1, y=e2 }` desugars as follows e { x=e1, y=e2 } ===> let { x' = e1; y' = e2 } in case e of T1 _ _ z -> T1 x' y' z T4 p _ _ -> T4 p y' x' The desugared expression is put into an HsExpansion, and we typecheck that. The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr. Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289 Updates haddock submodule
Diffstat (limited to 'testsuite/tests/typecheck/should_fail/T21158.stderr')
-rw-r--r--testsuite/tests/typecheck/should_fail/T21158.stderr29
1 files changed, 29 insertions, 0 deletions
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)