11
$\begingroup$

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.

$\endgroup$
4
  • 1
    $\begingroup$ I'm not quite following: Can you give one example of "executing any command" that does this? $\endgroup$ Jul 17, 2015 at 17:50
  • 6
    $\begingroup$ @Praan Try turning off the Suggestions bar. $\endgroup$
    – ilian
    Jul 17, 2015 at 17:57
  • $\begingroup$ @Arnoud Buzing Literally anything. Any Mathematica expression that is executed after assigning assoc clears assoc. $\endgroup$
    – Praan
    Jul 17, 2015 at 18:00
  • $\begingroup$ @ilian It worked! Thanks! $\endgroup$
    – Praan
    Jul 17, 2015 at 18:18

1 Answer 1

7
$\begingroup$

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.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.