[commit: ghc] wip/impredicativity: Fix bug on record construction typechecking (b9c79af)

git at git.haskell.org git at git.haskell.org
Wed Jul 22 08:45:24 UTC 2015


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

On branch  : wip/impredicativity
Link       : http://ghc.haskell.org/trac/ghc/changeset/b9c79afcf1492f5a916c8d3cb48fd7db521fc8e4/ghc

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

commit b9c79afcf1492f5a916c8d3cb48fd7db521fc8e4
Author: Alejandro Serrano <trupill at gmail.com>
Date:   Wed Jul 22 10:46:12 2015 +0200

    Fix bug on record construction typechecking


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

b9c79afcf1492f5a916c8d3cb48fd7db521fc8e4
 compiler/typecheck/TcExpr.hs | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/compiler/typecheck/TcExpr.hs b/compiler/typecheck/TcExpr.hs
index 987eb2c..c8de8a5 100644
--- a/compiler/typecheck/TcExpr.hs
+++ b/compiler/typecheck/TcExpr.hs
@@ -484,14 +484,18 @@ tcExpr (RecordCon (L loc con_name) _ rbinds) res_ty
         -- Check for missing fields
         ; checkMissingFields data_con rbinds
 
-        ; con_expr <- tcCheckId con_name res_ty
+        -- Get type of the constructor
+        ; (con_expr, _, con_sigma) <- tcIdOcc (OccurrenceOf con_name) con_name
+        ; (wrap, con_rho) <- instFunTy con_sigma  -- Eagerly instantiate
+
         ; let arity = dataConSourceArity data_con
-              (arg_tys, _actual_res_ty) = tcSplitFunTysN res_ty arity
+              (arg_tys, actual_res_ty) = tcSplitFunTysN con_rho arity
               con_id = dataConWrapId data_con
-
-        -- ; co_res <- unifyType actual_res_ty res_ty
+        ; co_res <- unifyType actual_res_ty res_ty
         ; rbinds' <- tcRecordBinds data_con arg_tys rbinds
-        ; return $ RecordCon (L loc con_id) con_expr rbinds' }
+
+        ; let record_con = RecordCon (L loc con_id) (mkHsWrap wrap con_expr) rbinds'
+        ; return $ mkHsWrapCo co_res record_con }
 
 {-
 Note [Type of a record update]



More information about the ghc-commits mailing list