Skip to content

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!

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