Skip to content

Motivation for let/app invariant

Motivation

From time to time I wonder why it's ok to allow unlifted let bindings and then have to re-read the let/app invariant. And after that, I'm still unconvinced that there is a good reason why we have unlifted let bindings and not just case expressions.

I think one of the reason is because then we have an easier time in FloatOut/SetLevels, but it seems like it already is aware of speculation for Case, see Note [Floating single-alternative cases].

Proposal

Get rid of the let/app invariant and case-bind all unlifted expressions in Core. Let bindings must always be lifted. Deal with the fall-out by calling exprOkForSpeculation on scrutinees to see whether they can be treated how unlifted let-bindings are treated at the moment.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information