Scala incorrectly optimizes away the if statement (without -optimize) in the following:
scala> val x = if(error("x")) 0d else -0d x: Double = 0.0 scala> val x = if(error("x")) 1d else 1d x: Double = 1.0
The main problem is that although `0d == -0d` is true, it is wrong to treat them as the same. It seems plausible this kind of constant equality check might be applied elsewhere as well.
Second, the side-effect in the if statement is discarded, although I don't know if there is a scenario where this could possibly matter.