I'm seeing some perplexing behavior from ValueQ
in 10.3. Consider:
f[r_List, n_Integer] := r^n;
ValueQ[f[{}, 1]]
(* ==> True *)
ValueQ[f[{}, 0.3]]
(* ==> False *)
ValueQ[f[{}, \[Pi]]]
(* ==> False *)
ValueQ[f[{a, b, c}, 3/2]]
(* ==> True *) (* THIS IS UNEXPECTED *)
f[{1,2,3}, 3/2]
(* ==> f[{1,2,3}, 3/2] *)
What I expect is that any ValueQ
call that has an argument list that matches the types in the function definition's pattern -- and therefore could be transformed by the rule associated with that definition -- will return True
. Any call with an argument list having different types will return False
. As I understand it, what ValueQ
does is test whether a rule exists that would transform its argument.
And that's what happens, EXCEPT for the final case, in which a {List,Rational}
slips through when only a {List,Integer}
should. ValueQ
returns True
. And yet, if I actually evaluate that function with those arguments, no transformation occurs, because (of course) no appropriate rule exists.
It seems that ValueQ
is simply failing. Is this a bug, or do I fail to understand some subtlety here?