fix: overflow check in subst(ideal..), #630