[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