Details
Description
This line of code incorrectly discards the return value. It's written like so:
idFields[i]->optimize(); // We optimize here to make use of constant folding.
|
But it should be this:
idFields[i] = idFields[i]->optimize(); // We optimize here to make use of constant folding.
|
The reason is that the Expression::optimize() function does not optimize the expression in place but rather returns a pointer to the optimized expression.
While we're at it, we should consider adding the "[[nodiscard]]" attribute to Expression::optimize() in order to try to prevent this kind of mistake in the future.