Bug introduced in 10.4.1 or earlier and persisting through 11.1.0 or later
Using x++ or x=x+1 inside Defer generates strange results.
Evaluating the following commands one by one (in three different input cells), with Shift+Enter, one gets:
x=1;
Defer[x++];
x
(* 15 but I have also seen 17! *)
Even stranger, if one creates a notebook with only those same commands, restarts the kernel, and does Evaluation ► Evaluate Notebook then the command x returns 1 instead of 15.
Any explanations?
1everytime, as I would expect... – ktm Oct 08 '16 at 22:171everytime. – anderstood Oct 08 '16 at 22:26Deferdoes not strike me as a bullet-proof way to prevent any and all internal evaluation. – Daniel Lichtblau Mar 19 '17 at 15:12