# Does the syntax coloring I see indicate a real problem?

I need a behaviour provided by:

x = 2;
Block[{x = HoldForm[x]}, x]

x


FrontEnd marks this syntax as not quite correct.

It has not caused me any troubles so far so my question is: could it be a problem?

-
I don't think it's a problem; the front end produces this coloring as a hint to the user that there could be a scoping inconsistency, not to say that the code is necessarily erroneous. The greater question in my mind is why does the FE apply the coloring in this particular case, which to me looks rather benign. (For others' reference, the FE is saying that x will go out of scope before being used. I must admit I don't understand what this even means for HoldForm.) –  Oleksandr R. May 23 '14 at 23:55
The notebook code editor is far from perfect. It produces strange coloration in many other situations. –  m_goldberg May 24 '14 at 2:26

There is one issue: It seems you cannot remove the HoldForm wrapper inside the Block. If you use x=HoldForm[a] instead, everything works as expected. Look at the output of this and then replace a by x. –  halirutan May 25 '14 at 1:28
I stumbled over this when I was trying to mess with the scoping by releasing the hold of x. I wanted to see what happens because the x inside the HoldForm is the global x. Obviously they prevented it. What consequences this has for your code, I don't know. –  halirutan May 25 '14 at 1:30