fixes error propagation in optimize.c

also fixes errors in https://github.com/D-Programming-Language/dmd/pull/2513