At the time erase_irrelevant is called, we have already eliminated the `cast`-applications. Therefore non-atomic expressions may no longer be well-typed (and `infer_type` can fail).