[commit: ghc] ghc-8.0: Fix interaction of record pattern synonyms and record wildcards (50e7157)

git at git.haskell.org git at git.haskell.org
Sun Oct 2 01:04:35 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/50e7157b97bf9bd06508fec656836b92668a859c/ghc

>---------------------------------------------------------------

commit 50e7157b97bf9bd06508fec656836b92668a859c
Author: Matthew Pickering <matthewtpickering at gmail.com>
Date:   Sat Oct 1 17:55:04 2016 -0400

    Fix interaction of record pattern synonyms and record wildcards
    
    We were missing an appropiate *ConLike lookup in the case when
    the pattern synonym was defined in a different module.
    
    Reviewers: austin, bgamari, simonpj
    
    Reviewed By: simonpj
    
    Subscribers: simonpj, thomie
    
    Differential Revision: https://phabricator.haskell.org/D2544
    
    GHC Trac Issues: #11987
    
    (cherry picked from commit 2d6642bd1956edf8b842c07d78e83c500246998a)


>---------------------------------------------------------------

50e7157b97bf9bd06508fec656836b92668a859c
 compiler/rename/RnEnv.hs                         |  4 ++--
 testsuite/tests/patsyn/should_compile/T11987.hs  | 12 ++++++++++++
 testsuite/tests/patsyn/should_compile/T11987a.hs |  9 +++++++++
 testsuite/tests/patsyn/should_compile/all.T      |  2 ++
 4 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/compiler/rename/RnEnv.hs b/compiler/rename/RnEnv.hs
index f8f6eea..100a0ef 100644
--- a/compiler/rename/RnEnv.hs
+++ b/compiler/rename/RnEnv.hs
@@ -458,9 +458,9 @@ lookupConstructorFields con_name
              ; traceTc "lookupCF" (ppr con_name $$ ppr (lookupNameEnv field_env con_name) $$ ppr field_env)
              ; return (lookupNameEnv field_env con_name `orElse` []) }
           else
-          do { con <- tcLookupDataCon con_name
+          do { con <- tcLookupConLike con_name
              ; traceTc "lookupCF 2" (ppr con)
-             ; return (dataConFieldLabels con) } }
+             ; return (conLikeFieldLabels con) } }
 
 -----------------------------------------------
 -- Used for record construction and pattern matching
diff --git a/testsuite/tests/patsyn/should_compile/T11987.hs b/testsuite/tests/patsyn/should_compile/T11987.hs
new file mode 100644
index 0000000..eab3316
--- /dev/null
+++ b/testsuite/tests/patsyn/should_compile/T11987.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE NamedFieldPuns, PatternSynonyms, RecordWildCards #-}
+module T11987 where
+
+import T11987a
+
+-- works
+namedFieldPuns :: (Int,Int)
+namedFieldPuns = let { x = 1; y = 2 } in Point { x, y }
+
+-- error: Pattern synonym ‘Point’ used as a data constructor
+recordWildCards :: (Int,Int)
+recordWildCards = let { x = 1; y = 2 } in Point { .. }
diff --git a/testsuite/tests/patsyn/should_compile/T11987a.hs b/testsuite/tests/patsyn/should_compile/T11987a.hs
new file mode 100644
index 0000000..c381c2b
--- /dev/null
+++ b/testsuite/tests/patsyn/should_compile/T11987a.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE NamedFieldPuns, PatternSynonyms, RecordWildCards #-}
+module T11987a where
+
+pattern Point :: Int -> Int -> (Int, Int)
+pattern Point{x, y} = (x, y)
+
+-- works
+sameFile :: (Int,Int)
+sameFile = let { x = 1; y = 2 } in Point { .. }
diff --git a/testsuite/tests/patsyn/should_compile/all.T b/testsuite/tests/patsyn/should_compile/all.T
index 8afa2b6..0300915 100644
--- a/testsuite/tests/patsyn/should_compile/all.T
+++ b/testsuite/tests/patsyn/should_compile/all.T
@@ -56,3 +56,5 @@ test('T12484', normal, compile, [''])
 test('T12489', normal, compile, [''])
 test('T11959', expect_broken(11959), multimod_compile, ['T11959', '-v0'])
 test('T12615', normal, compile, [''])
+test('T11987', normal, multimod_compile, ['T11987', '-v0'])
+



More information about the ghc-commits mailing list