WorkWrap: Remove mkWWargs (#19874) and add regression test for #17819

Closed Sebastian Graf requested to merge wip/19874 into master

mkWWargs's job was pushing casts inwards and doing eta expansion to match the arity with the number of argument demands we w/w for.

Nowadays, we use the Simplifier to eta expand to arity. In fact, in recent years we have even seen the eta expansion done by w/w as harmful, see Note [Don't eta expand in w/w]. If a function hasn't enough manifest lambdas, don't w/w it!

What purpose does mkWWargs serve in this world? Not a great one, it turns out! I could remove it by pulling some important bits, notably Note [Freshen WW arguments] and Note [Join points and beta-redexes]. Result: We reuse the freshened binder names of the wrapper in the worker where possible (see testuite changes), much nicer!

In order to avoid scoping errors due to lambda-bound unfoldings in worker arguments, we zap those unfoldings now. In doing so, we fix #19766 (closed).

Fixes #19874 (closed).

Edited by Sebastian Graf

Merge request reports