Commit 40887990 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Mark evaluated arguments in dataConInstPat

See Note [Mark evaluated arguments] in CoreUtils.

This is not a significant change, but avoids a spurious Lint complaint.
parent 0f978b5b
......@@ -1257,7 +1257,7 @@ dataConInstPat fss uniqs con inst_tys
univ_tvs = dataConUnivTyVars con
ex_tvs = dataConExTyVars con
arg_tys = dataConRepArgTys con
arg_strs = dataConRepStrictness con -- 1-1 with arg_tys
n_ex = length ex_tvs
-- split the Uniques and FastStrings
......@@ -1280,11 +1280,30 @@ dataConInstPat fss uniqs con inst_tys
kind = Type.substTy subst (tyVarKind tv)
-- Make value vars, instantiating types
arg_ids = zipWith3 mk_id_var id_uniqs id_fss arg_tys
mk_id_var uniq fs ty = mkUserLocal (mkVarOccFS fs) uniq
(Type.substTy full_subst ty) noSrcSpan
arg_ids = zipWith4 mk_id_var id_uniqs id_fss arg_tys arg_strs
mk_id_var uniq fs ty str
= mkLocalIdWithInfo name (Type.substTy full_subst ty) info
where
name = mkInternalName uniq (mkVarOccFS fs) noSrcSpan
info | isMarkedStrict str = vanillaIdInfo `setUnfoldingInfo` evaldUnfolding
| otherwise = vanillaIdInfo
-- See Note [Mark evaluated arguments]
\end{code}
Note [Mark evaluated arguments]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When pattern matching on a constructor with strict fields, the binder
can have an 'evaldUnfolding'. Moreover, it *should* have one, so that
when loading an interface file unfolding like:
data T = MkT !Int
f x = case x of { MkT y -> let v::Int# = case y of I# n -> n+1
in ... }
we don't want Lint to complain. The 'y' is evaluated, so the
case in the RHS of the binding for 'v' is fine. But only if we
*know* that 'y' is evaluated.
c.f. add_evals in Simplify.simplAlt
%************************************************************************
%* *
Equality
......
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