I encountered this problem and was unpleasantly surprised. Let us define a function:
k is supposed to be a dummy variable, right?
Let us calculate
g[x+t], you get
1+t+x+(t+x)^2, all good.
So you should remember all summation variables used in functions and never use them as external variables. I encountered this problem and couldn't understand why it is giving the wrong answer. Looks like a bug to me.