Commit 2d6642bd authored by Matthew Pickering's avatar Matthew Pickering Committed by Ben Gamari
Browse files

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
parent c93813d9
......@@ -462,9 +462,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
......
{-# 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 { .. }
{-# 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 { .. }
......@@ -58,4 +58,5 @@ test('T12094', normal, compile, [''])
test('T11977', normal, compile, [''])
test('T12108', normal, compile, [''])
test('T12484', normal, compile, [''])
test('T12489', normal, compile, [''])
test('T11987', normal, multimod_compile, ['T11987', '-v0'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment