fixes #231: infinite optimisation loop in side-effect-free programs