Skip to content

`exprOkForSpeculation` for Note [IO hack in the demand analyser]

Sebastian Graf requested to merge wip/T14998 into master

In #14998 (closed) I realised that the notion of speculative execution exactly matches eager evaluation of expressions in a case alternative where the scrutinee is an IO action.

Normally we have to deferIO any result from that single case alternative to prevent this speculative execution, so we had a special case in place in the demand analyser that would check if the scrutinee was a prim-op, in which case we assumed that it would be ok to do the eager evaluation.

Now we just check if the scrutinee is exprOkForSpeculation, corresponding to the notion that we want to push evaluation of the scrutinee after eagerly evaluating stuff from the case alternative.

This fixes #14998 (closed), because it resolves the last open Item 4 there.

Edited by Sebastian Graf

Merge request reports