For me I already get an error for func[[i]]
:
In[20]:= func[x_] := x^2 + 2
In[21]:= func[[2]]
During evaluation of In[21]:= Part::partd: Part specification func[[2]] is longer than depth of object.
Out[21]= func[[2]]
So then the problem comes when using a List
as the head of an expression. One way to make sure a message is issued for that case would be to define $Post
:
In[22]:= list::notfunc = "Warning: list used as a function.";
$Post = ReplaceAll[x : (_List)[arg___] :> (Message[list::notfunc]; x)];
In[24]:= list = {1, 2, 3, 4};
In[25]:=list[3]
During evaluation of In[24]:= list::notfunc: Warning: list used as a function.
Out[25]= {1, 2, 3, 4}[3]