Inject implicit bindings after CoreTidy, not before Simplify
authorsimonpj@microsoft.com <unknown>
Mon, 8 Dec 2008 17:35:25 +0000 (17:35 +0000)
committersimonpj@microsoft.com <unknown>
Mon, 8 Dec 2008 17:35:25 +0000 (17:35 +0000)
commit19fcb519897270c9fcd2c0f707636e9682ff1b08
tree0476c6bca61160d95aa6b852678975a5e9301ad7
parent60881299e5fbceff0eec48fa58bc0eff24640ba3
Inject implicit bindings after CoreTidy, not before Simplify

Originally I inject the "implicit bindings" (record selectors, class
method selectors, data con wrappers...) after CoreTidy.  However, in a
misguided attempt to fix Trac #2070, I moved the injection point to
before the Simplifier, so that record selectors would be optimised by
the simplifier.

This was misguided because record selectors (indeed all implicit bindings)
are GlobalIds, whose IdInfo is meant to be frozen.  But the Simplifier,
and other Core-to-Core optimisations, merrily change the IdInfo.  That
ultimately made Trac #2844 happen, where a record selector got arity 2,
but the GlobalId (which importing scopes re-construct from the class decl
rather than reading from the interface file) has arity 1.

So this patch moves the injection back to CoreTidy. Happily #2070 should
still be OK because we now use CoreSubst.simpleOptExpr on the unfoldings
for implict things, which gets rid of the most gratuitous infelicities.

Still, there's a strong case for stoppping record selectors from being
GlobalIds, and treating them much more like dict-funs.  I'm thinking
about that.  Meanwhile, #2844 is ok now.
compiler/main/TidyPgm.lhs
compiler/simplCore/SimplCore.lhs