Inconsistency around unsafeEqualityProof
From Note [Implementing unsafeCoerce]
in base:Unsafe.Coerce
:
But what stops the whole (case unsafeEqualityProof of ...) from
floating? Answer: we never float a case on a redex that can fail
outside a conditional. See Primop.hs,
Note [Transformations affected by primop effects].
And unsafeEqualityProof (being opaque) is definitely treated as
can-fail.
But actually we have a special case in exprOkForSpeculation
that specifically treats unsafeEqualityProof
as OK-for-speculation, i.e. OK to float out and evaluate eagerly. This is very suspicious!