Commit 3e00d046 authored by Simon Peyton Jones's avatar Simon Peyton Jones

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.
parent 48cab6d4
......@@ -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 ]
......
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