summaryrefslogtreecommitdiff
path: root/compiler/rename/RnPat.lhs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2012-03-04 09:41:52 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2012-03-04 09:41:52 +0000
commit3e00d04619bb504e3cbe766eaf29e746d1211652 (patch)
treeceebdf5ff6ab0911ac4a7ab3527dc66744c3892f /compiler/rename/RnPat.lhs
parent48cab6d497b3e1dafb3ddbfadc64417ca655051f (diff)
downloadhaskell-3e00d04619bb504e3cbe766eaf29e746d1211652.tar.gz
Fix Trac #5892: a coding errors
We had a lazy pattern gres@(gre:_) = blah and then a test for (null gres). But I'd forgotten that a demand for *any* of variables in the pattern matches *all* of the variables in the entire pattern. So the test for (null gres) was matching the cons, which defeats the purpose.
Diffstat (limited to 'compiler/rename/RnPat.lhs')
-rw-r--r--compiler/rename/RnPat.lhs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rename/RnPat.lhs b/compiler/rename/RnPat.lhs
index 162ce22775..d0302a19a2 100644
--- a/compiler/rename/RnPat.lhs
+++ b/compiler/rename/RnPat.lhs
@@ -502,7 +502,7 @@ rnHsRecFields1 ctxt mk_arg (HsRecFields { rec_flds = flds, rec_dotdot = dotdot }
= return []
rn_dotdot (Just {}) Nothing _flds -- ".." on record update
= do { addErr (badDotDot ctxt); return [] }
- rn_dotdot (Just n) (Just con) flds -- ".." on record con/pat
+ rn_dotdot (Just n) (Just con) flds -- ".." on record construction / pat match
= ASSERT( n == length flds )
do { loc <- getSrcSpanM -- Rather approximate
; dd_flag <- xoptM Opt_RecordWildCards
@@ -526,11 +526,11 @@ rnHsRecFields1 ctxt mk_arg (HsRecFields { rec_flds = flds, rec_dotdot = dotdot }
where
rdr = mkRdrUnqual (nameOccName fld)
- dot_dot_gres = [ gre
+ dot_dot_gres = [ head gres
| fld <- con_fields
, not (fld `elem` present_flds)
- , let gres@(gre:_) = lookupGRE_Name rdr_env fld
- , not (null gres)
+ , let gres = lookupGRE_Name rdr_env fld
+ , not (null gres) -- Check field is in scope
, case ctxt of
HsRecFieldCon {} -> arg_in_scope fld
_other -> True ]