[commit: ghc] master: Make the demand on a binder compatible with type (fixes Trac #8569) (4b355cd)
git at git.haskell.org
git at git.haskell.org
Thu Mar 6 12:17:25 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/4b355cd21a190e3d2c2d3a830ba2337d1c442dfe/ghc
>---------------------------------------------------------------
commit 4b355cd21a190e3d2c2d3a830ba2337d1c442dfe
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Thu Mar 6 11:31:47 2014 +0000
Make the demand on a binder compatible with type (fixes Trac #8569)
Because of GADTs and casts we were getting binders whose
demand annotation was more deeply nested than made sense
for its type.
See Note [Trimming a demand to a type], in Demand.lhs,
which I reproduce here:
Note [Trimming a demand to a type]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this:
f :: a -> Bool
f x = case ... of
A g1 -> case (x |> g1) of (p,q) -> ...
B -> error "urk"
where A,B are the constructors of a GADT. We'll get a U(U,U) demand
on x from the A branch, but that's a stupid demand for x itself, which
has type 'a'. Indeed we get ASSERTs going off (notably in
splitUseProdDmd, Trac #8569).
Bottom line: we really don't want to have a binder whose demand is more
deeply-nested than its type. There are various ways to tackle this.
When processing (x |> g1), we could "trim" the incoming demand U(U,U)
to match x's type. But I'm currently doing so just at the moment when
we pin a demand on a binder, in DmdAnal.findBndrDmd.
>---------------------------------------------------------------
4b355cd21a190e3d2c2d3a830ba2337d1c442dfe
compiler/basicTypes/Demand.lhs | 62 +++++++++++++++++++++++++++++++++++++-
compiler/stranal/DmdAnal.lhs | 64 +++++++++++++++++++++-------------------
compiler/stranal/WwLib.lhs | 31 ++++++++++++++++++-
3 files changed, 124 insertions(+), 33 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 4b355cd21a190e3d2c2d3a830ba2337d1c442dfe
More information about the ghc-commits
mailing list