Skip to content
  • Sebastian Graf's avatar
    `exprOkForSpeculation` for Note [IO hack in the demand analyser] · ce64b397
    Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
    In #14998 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 #14988, because it resolves the last open Item 4 there.
    ce64b397