Bug introduced in 7.0 or earlier and persisting through 11.0
While looking at A question about conditional replacement I think I discovered a bug in the Front End that affects both 7.0.1 and 10.0.1 under Windows.
If I copy and paste this line into a new Cell in a Notebook:
{g[x, y, z], h[x, y], f[]} /. (f_[t___] /; f != List) :> Plus[t]
then select ≠
(auto-converted to single character) and type over it =!=
and evaluate I get:
{g[x, y, z], h[x, y], f[]}
Rather than the expected:
{x + y + z, x + y, 0}
If I use menu Cell > Convert To > InputForm the input cell is converted to:
{g[x, y, z], h[x, y], f[]} /. ((f_)[t___] /; f) =!= List :> Plus[t]
Note the parentheses: ((f_)[t___] /; f)
is grouped separately from =!= List
. The RHS therefore evaluates to:
True :> +t
Does this problem affect all recent versions on all platforms or is it more localized?
Cell
toInputForm
I just add//Hold
at the end of the expression and evaluate it again. $\endgroup$=!=
, or edit anything else inside the parantheses, it gives the expected output. $\endgroup$=!=
you can simply go left of thef
and press Ctrl+. for expand selection. You see that the front-end parses it incorrectly because/;
seems to have a higher precedence. Weird. Btw, M8.0.4 on OSX. $\endgroup$