summaryrefslogtreecommitdiff
path: root/compiler/deSugar/DsExpr.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2016-12-21 12:24:41 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2016-12-21 12:26:24 +0000
commit1a4c04b13a695a530ee24835a7550a8c9ed2d37a (patch)
tree6bec42a3a6538d8e26985f4929f49bf257bbf814 /compiler/deSugar/DsExpr.hs
parentc48595eef2bca6d91ec0a649839f8066f269e6a4 (diff)
downloadhaskell-1a4c04b13a695a530ee24835a7550a8c9ed2d37a.tar.gz
Fix 'SPECIALISE instance'
Trac #12944 showed that the DsBinds code that implemented a SPECIALISE pragma was inadequate if the constraints solving added let-bindings for dictionaries. The result was that we ended up with an unbound dictionary in a DFunUnfolding -- and Lint didn't even check for that! Fixing this was not entirely straightforward * In DsBinds.dsSpec we use a new function TcEvidence.collectHsWrapBinders to pick off the lambda binders from the HsWapper * dsWrapper now returns a (CoreExpr -> CoreExpr) function * CoreUnfold.specUnfolding now takes a (CoreExpr -> CoreExpr) function it can use to specialise the unfolding. On the whole the code is simpler than before.
Diffstat (limited to 'compiler/deSugar/DsExpr.hs')
-rw-r--r--compiler/deSugar/DsExpr.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/deSugar/DsExpr.hs b/compiler/deSugar/DsExpr.hs
index a08c3ac7cb..214cb0bb32 100644
--- a/compiler/deSugar/DsExpr.hs
+++ b/compiler/deSugar/DsExpr.hs
@@ -214,8 +214,9 @@ dsExpr (HsOverLit lit) = dsOverLit lit
dsExpr (HsWrap co_fn e)
= do { e' <- dsExpr e
- ; wrapped_e <- dsHsWrapper co_fn e'
+ ; wrap' <- dsHsWrapper co_fn
; dflags <- getDynFlags
+ ; let wrapped_e = wrap' e'
; warnAboutIdentities dflags e' (exprType wrapped_e)
; return wrapped_e }
@@ -748,9 +749,11 @@ dsSyntaxExpr (SyntaxExpr { syn_expr = expr
, syn_arg_wraps = arg_wraps
, syn_res_wrap = res_wrap })
arg_exprs
- = do { args <- zipWithM dsHsWrapper arg_wraps arg_exprs
- ; fun <- dsExpr expr
- ; dsHsWrapper res_wrap $ mkApps fun args }
+ = do { fun <- dsExpr expr
+ ; core_arg_wraps <- mapM dsHsWrapper arg_wraps
+ ; core_res_wrap <- dsHsWrapper res_wrap
+ ; let wrapped_args = zipWith ($) core_arg_wraps arg_exprs
+ ; return (core_res_wrap (mkApps fun wrapped_args)) }
findField :: [LHsRecField Id arg] -> Name -> [arg]
findField rbinds sel