Bug introduced in 10.0.0 and fixed in 10.1.0.
While answering Pattern match for nested Association I came across behavior of MemberQ
and FreeQ
in 10.0.1 that I believe is incorrect. The option Heads -> False
does not work properly:
expr1 = foo[bar, baz];
expr2 = <|1 -> a, 2 -> b|>;
MemberQ[expr1, _?Print, Heads -> False];
bar
baz
MemberQ[expr2, _?Print, Heads -> False];
Association
a
b
FreeQ[expr1, _?Print, Heads -> False];
bar
baz
foo[bar,baz]
FreeQ[expr2, _?Print, Heads -> False];
Association
a
b
<|1->a,2->b|>
Observe that in both cases Association
is checked against the pattern even though foo
is not.
Sjoerd wrote:
I believe the error is not the printing of
Association
but that it prints anything at all.Association
is atomic and it should have no (visible) members. Compare withexpr3=Graph[{1->2}]
.
The 10.0.1 documentation says:
MemberQ
works on associations, testing values but not keys.
FreeQ
works on associations, testing values but not keys.
Therefore this overloading is documented and I believe options should work propertly.
Association
but that it prints anything at all.Association
is atomic and it should have no (visible) members. Compare withexpr3=Graph[{1->2}]
. $\endgroup$ – Sjoerd C. de Vries Oct 8 '14 at 19:06