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:

(* 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?

  • $\begingroup$ I get 1 everytime, as I would expect... $\endgroup$
    – ktm
    Oct 8, 2016 at 22:17
  • 7
    $\begingroup$ First check: turn off the Suggestions Bar and try again. $\endgroup$
    – Mr.Wizard
    Oct 9, 2016 at 2:18
  • 4
    $\begingroup$ @Mr.Wizard - Turning off the Suggestions Bar fixes the problem. Thanks. $\endgroup$
    – Soldalma
    Oct 9, 2016 at 11:03
  • 2
    $\begingroup$ @Mr.Wizard What do we do with questions like this? Close it as a duplicate of what you linked? Close it as a duplicate of another question about a Suggestion Bar bug? Post an answer? I'm really disturbed by the amount of problems the Suggestion Bar causes. I think it says more about how difficult it is to manipulate code in Mathematica than about WRI quality control. I would never have dared to attempt to implement something like this myself—the risk of evaluation leaks is much too great. $\endgroup$
    – Szabolcs
    Oct 9, 2016 at 12:50
  • 1
    $\begingroup$ @Szabolcs - I reported the bug. $\endgroup$
    – Soldalma
    Oct 9, 2016 at 18:27


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.