summaryrefslogtreecommitdiff
path: root/compiler/typecheck/TcPat.hs
diff options
context:
space:
mode:
authorAdam Gundry <adam@well-typed.com>2017-09-19 19:03:16 -0400
committerBen Gamari <ben@smart-cactus.org>2017-09-21 11:30:38 -0400
commit72b00c34c73ff6c63ee4928006b0cc60034a7638 (patch)
tree773a20b899fe342a1d928d37b170dbb4f319487d /compiler/typecheck/TcPat.hs
parent9e46d88adeea1fd399dff1208aa5710d696c542c (diff)
downloadhaskell-72b00c34c73ff6c63ee4928006b0cc60034a7638.tar.gz
Identify fields by selector when type-checking (fixes #13644)
Test Plan: new test for #13847, and the test for #13644 now passes Reviewers: mpickering, austin, bgamari, simonpj Reviewed By: mpickering, simonpj Subscribers: simonpj, rwbarton, thomie GHC Trac Issues: #13644, #13847 Differential Revision: https://phabricator.haskell.org/D3988
Diffstat (limited to 'compiler/typecheck/TcPat.hs')
-rw-r--r--compiler/typecheck/TcPat.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/typecheck/TcPat.hs b/compiler/typecheck/TcPat.hs
index f2188af006..c5e367e3be 100644
--- a/compiler/typecheck/TcPat.hs
+++ b/compiler/typecheck/TcPat.hs
@@ -985,14 +985,15 @@ tcConArgs con_like arg_tys (RecCon (HsRecFields rpats dd)) penv thing_inside
tc_field (L l (HsRecField (L loc (FieldOcc (L lr rdr) sel)) pat pun)) penv
thing_inside
= do { sel' <- tcLookupId sel
- ; pat_ty <- setSrcSpan loc $ find_field_ty (occNameFS $ rdrNameOcc rdr)
+ ; pat_ty <- setSrcSpan loc $ find_field_ty sel
+ (occNameFS $ rdrNameOcc rdr)
; (pat', res) <- tcConArg (pat, pat_ty) penv thing_inside
; return (L l (HsRecField (L loc (FieldOcc (L lr rdr) sel')) pat'
pun), res) }
- find_field_ty :: FieldLabelString -> TcM TcType
- find_field_ty lbl
- = case [ty | (fl, ty) <- field_tys, flLabel fl == lbl] of
+ find_field_ty :: Name -> FieldLabelString -> TcM TcType
+ find_field_ty sel lbl
+ = case [ty | (fl, ty) <- field_tys, flSelector fl == sel] of
-- No matching field; chances are this field label comes from some
-- other record type (or maybe none). If this happens, just fail,