Ideally we'd like to do this by checking whether the operation is legal but for now this will do.
mentioned in commit ce5c9bde