diff options
author | CarrieMY <carrie.xmy@gmail.com> | 2022-05-25 16:43:03 +0200 |
---|---|---|
committer | sheaf <sam.derbyshire@gmail.com> | 2022-05-25 16:43:03 +0200 |
commit | e74fc066cb33e5b7ae0d37cedb30230c597ef1ce (patch) | |
tree | cc17cbbe235ada53bdac93e06cbfe4ca632ffa4a /testsuite/tests/patsyn/should_fail | |
parent | 2ff18e390b119c611b3dd429b76cfcbf36ef9545 (diff) | |
download | haskell-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/patsyn/should_fail')
5 files changed, 5 insertions, 28 deletions
diff --git a/testsuite/tests/patsyn/should_fail/all.T b/testsuite/tests/patsyn/should_fail/all.T index 2db852a35b..9879f2d9b0 100644 --- a/testsuite/tests/patsyn/should_fail/all.T +++ b/testsuite/tests/patsyn/should_fail/all.T @@ -15,7 +15,6 @@ test('records-no-uni-update', normal, compile_fail, ['']) test('records-no-uni-update2', normal, compile_fail, ['']) test('records-mixing-fields', normal, compile_fail, ['']) test('records-exquant', normal, compile_fail, ['']) -test('records-poly-update', normal, compile_fail, ['']) test('records-nofieldselectors', normal, compile_fail, ['']) test('mixed-pat-syn-record-sels', normal, compile_fail, ['']) test('T11039', normal, compile_fail, ['']) diff --git a/testsuite/tests/patsyn/should_fail/records-exquant.stderr b/testsuite/tests/patsyn/should_fail/records-exquant.stderr index b5c3fddcc3..2f3a0f508b 100644 --- a/testsuite/tests/patsyn/should_fail/records-exquant.stderr +++ b/testsuite/tests/patsyn/should_fail/records-exquant.stderr @@ -4,8 +4,3 @@ records-exquant.hs:8:7: error: • In the expression: a (Showable True) In an equation for ‘qux’: qux = a (Showable True) Suggested fix: Use pattern-matching syntax instead - -records-exquant.hs:10:7: error: - • Record update for insufficiently polymorphic field: a :: a - • In the expression: (Showable ()) {a = True} - In an equation for ‘foo’: foo = (Showable ()) {a = True} diff --git a/testsuite/tests/patsyn/should_fail/records-no-uni-update.stderr b/testsuite/tests/patsyn/should_fail/records-no-uni-update.stderr index 71e2a99407..c7e60f1085 100644 --- a/testsuite/tests/patsyn/should_fail/records-no-uni-update.stderr +++ b/testsuite/tests/patsyn/should_fail/records-no-uni-update.stderr @@ -1,5 +1,7 @@ records-no-uni-update.hs:7:7: error: - non-bidirectional pattern synonym ‘Uni’ used in an expression - In the expression: ("a", "b") {a = "b"} - In an equation for ‘foo’: foo = ("a", "b") {a = "b"} + • non-bidirectional pattern synonym ‘Uni’ used in an expression + • In a record update at field ‘a’ + and with pattern synonym ‘Uni’. + In the expression: ("a", "b") {a = "b"} + In an equation for ‘foo’: foo = ("a", "b") {a = "b"} diff --git a/testsuite/tests/patsyn/should_fail/records-poly-update.hs b/testsuite/tests/patsyn/should_fail/records-poly-update.hs deleted file mode 100644 index f488b18bc6..0000000000 --- a/testsuite/tests/patsyn/should_fail/records-poly-update.hs +++ /dev/null @@ -1,13 +0,0 @@ -{-# LANGUAGE PatternSynonyms #-} -module Main where - -pattern ReqNoProv :: Show a => a -> Maybe a -pattern ReqNoProv{j} = Just j - -data A = A deriving Show - -p1 = Just True - -p6 = p1 {j = A} - -main = print p6 diff --git a/testsuite/tests/patsyn/should_fail/records-poly-update.stderr b/testsuite/tests/patsyn/should_fail/records-poly-update.stderr deleted file mode 100644 index 44bee9b2c3..0000000000 --- a/testsuite/tests/patsyn/should_fail/records-poly-update.stderr +++ /dev/null @@ -1,6 +0,0 @@ - -records-poly-update.hs:11:14: error: - • Couldn't match expected type ‘Bool’ with actual type ‘A’ - • In the ‘j’ field of a record - In the expression: p1 {j = A} - In an equation for ‘p6’: p6 = p1 {j = A} |