[project @ 2005-10-17 11:10:36 by simonpj]
authorsimonpj <unknown>
Mon, 17 Oct 2005 11:10:36 +0000 (11:10 +0000)
committersimonpj <unknown>
Mon, 17 Oct 2005 11:10:36 +0000 (11:10 +0000)
commitb16992d66aa5f610de586eb8a720214b8065bd65
tree8532bdaac631a97a7fce364f3ad3df90910c70c1
parente8883060ab278b5d4ceda2e75780a302146015c6
[project @ 2005-10-17 11:10:36 by simonpj]
Small simplifier bug in case optimisation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The simplifier eliminates redundant case branches, and panics if there
are no case alternatives.  But due to a slightly delayed instantiation
of a type constructor variable 'p' by a type constructor 'P', it turned
out that an inner case had no alternatives at all, becuase an outer case
had not pruned a branch as quickly as it should have.

This commit fixes both problems:

a) SimplUtils.mkCase1 now returns a call to 'error' (instead of panicing)
   when it gets an empty list of alternatives.   Somewhat analogous to
   the inaccessible GADT case in Simplify.simplifyAlt

b) In SimplUtils.prepareDefault, use the up-to-date scrutinee, rather than
   the less up-to-date case_bndr, to get the case type constructor.  That
   leads to slightly earlier pruning of inaccessible branches.

Fixes a bug reported by Ian Lynagh.

Test is simplCore/should_compile/simpl013
ghc/compiler/simplCore/SimplUtils.lhs