Localization of values in Block[] not working

I don’t quite understand localization of variable values in Block[]. Executing this code in the front end:

w = 1.11;
Block[{w}, w = 2;  Plot[Sin[w x], {x, 0, 2 Pi}]]

leaves the value of w as 2. If I change it to:

w = 1.11;
Block[{w}, w = 2; Print[Plot[Sin[w x], {x, 0, 2 Pi}]]]

then the value of w is 1.11 after executing, as I expect.

Why is w not restored in the first instance?
Any help appreciated… problem is, I know how to fix this case, but now I am unsure of when Block[] does and does not restore values of local variables.

–Phil

I tried your first example and I get that w is 1.11 after executing it as I’d expect. Try your examples again in a fresh version of Mathematica with a fresh kernel.

I rebooted the computer, and reset Mathematica by deleting the User and UserBase directories, but still get the same result:

Still, good to know it’s supposed to work the way I thought. I have been having other issues with this release, for example using Clear[] seems to clear a variable even if it set later as part of the same input cell, unless it is used in the ouput of that cell:

The value of w being 2 is due to an evaluation leak from a predictive interface rule being applied behind the scenes. For now, you may avoid this by turning the suggestion bar off in Preferences → Interface.

..and the difference between our two experiences is that I have the predictive interface turned off… :wink:

Thanks Ilian, that resolved both problems.