Executing Trace
on an expression reveals what is actually happening:
Trace[Remove@x; x = 1]
(*{Remove[Removed[x]];Removed[x]=1,{Remove[Removed[x]],Null},{Removed[x]=1,1},1}*)
"the Wolfram Language always reads in a complete input expression, and interprets the names in it, before it executes any part of the expression." (see: https://reference.wolfram.com/language/tutorial/SettingUpWolframLanguagePackages.html)
The whole line is one expression with the head CompoundExpression
. The variable x
gets replaced with Removed["x"]
throughout that expression. Then it seems that Removed["x"]
is assigned the value 1 (see Leonid Shifrin's answer to this questionquestion for more details about Removed symbols).
However, when you write it on two different lines, it is interpreted as two separate expressions and hence you don't face this problem.