Fix exprIsConApp_maybe
authorSimon Peyton Jones <simonpj@microsoft.com>
Thu, 21 Feb 2019 12:03:22 +0000 (12:03 +0000)
committerMatthew Pickering <matthewtpickering@gmail.com>
Fri, 22 Feb 2019 06:56:08 +0000 (06:56 +0000)
commitc25b135ff5b9c69a90df0ccf51b04952c2dc6ee1
tree7687cebc851d686fd72b2ad69dc0841b3d281f88
parent0eb7cf03da3783ca887d5de44d312cf6f3a4113c
Fix exprIsConApp_maybe

In this commit
   commit 7833cf407d1f608bebb1d38bb99d3035d8d735e6
   Date:   Thu Jan 24 17:58:50 2019 +0100
      Look through newtype wrappers (Trac #16254)

we made exprIsConApp_maybe quite a bit cleverer.  But I had not paid
enough attention to keeping exactly the correct substitution and
in-scope set, which led to Trac #16348.

There were several buglets (like applying the substitution twice in
exprIsConApp_maybe, but the proximate source of the bug was that we were
calling addNewInScopeIds, which deleted things from the substitution as
well as adding them to the in-scope set.  That's usually right, but not
here!

This was quite tricky to track down.  But it is nicer now.
compiler/basicTypes/MkId.hs
compiler/coreSyn/CoreOpt.hs
compiler/prelude/PrelRules.hs
compiler/simplCore/Simplify.hs
testsuite/tests/simplCore/should_compile/T16348.hs [new file with mode: 0644]
testsuite/tests/simplCore/should_compile/all.T