11

Bug introduced in 10.1 or earlier and fixed in 10.3


According to the documentation, in order to make sure that a value in an association is not evaluated at initialization, one can use a RuleDelayed. This works fine:

Clear[x]
assoc = <| "a" -> x, "b" :> (x = 1;) |>;

{ assoc["a"], assoc["b"]; assoc["a"] }

Now, I want to have a key that clears the association if I extract its value. Like this:

assoc = <| "clear" :> Clear[assoc] |>;

However, any Mathematica expression that is executed after assigning assoc clears assoc (in Mathematica 10.1). What is going on?

Edit

It turns out this is a bug caused by the Suggestions Bar as pointed out by the user ilian. Turning off the Suggestions Bar in Edit->Preferences->Interface fixed the issue.

Michael E2
  • 235,386
  • 17
  • 334
  • 747
Praan
  • 683
  • 4
  • 15

1 Answers1

7

To turn my comment into an answer, this seems to be an evaluation leak coming from the Predictive Interface. I've let the appropriate developers know and they will look into it.

A workaround for now would be to turn off the Suggestions bar.

ilian
  • 25,474
  • 4
  • 117
  • 186