4

Bug introduced in 10.0 and fixed in 10.1


Why is the variable a ending up assigned to {1,2,3} after executing

Module[{a},
a=Range[3];
ListPlot[a]
]
Michael E2
  • 235,386
  • 17
  • 334
  • 747

2 Answers2

6

This is yet another bug caused by the Suggestions Bar.

Workaround:

  • Go to Preferences... -> Interface, and uncheck "Show Suggestions Bar after last output".

I can reproduce it on OS X, Mathematica 10.0.2, but not in version 9.0.1.


Whenever I see that some people can reproduce a bug, some can't, I turn on the Suggestion Bar and check if it's the culprit. Very often it is. That's why I keep it off.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
  • 2
    A-ha! I turned off the Suggestions Bar long ago as soon as I found out that I could. I did not realize it also had such a side effect. Its popping in and out of existence is enough of a headache for me. +1 – Michael E2 Feb 17 '15 at 22:07
0

Very strange!

If you put an "a" after it works as expected:

Module[{a}, a = Range[3];
 ListPlot[a]]
a

It also works if you suppress the Module's output (but not ListPlot's):

Module[{a}, a = Range[3];
  Print@ListPlot[a]];
Aisamu
  • 2,618
  • 14
  • 17
  • 1
    This is yet another symptom of Sugestions Bar caused trouble. Putting the a at the end prevents the Suggestions Bar from messing with the previous output. – Szabolcs Feb 17 '15 at 20:38