-
-
Notifications
You must be signed in to change notification settings - Fork 61
Description
Description
When a builtin function has the Flat attribute (as happens in the Union builtin), and we have a particular kind of pattern, the matching will not pass a full flattened list.
How to Reproduce
Consider this pattern docstring for Union:
"Union[lists__, SameTest->sametest_]"If we encounter:
Union[{1, -1, -2}, {2, 3}, SameTest -> (Abs[#1] == Abs[#2] &)]
and Union has the "Flat" attribute (flatten lists), then the pattern matches, but the eval() method gets passed {1, -1, -2} for list rather than {{1, -1, -2, 2, 3}.
If instead Union does not have the Flat attribute, the pattern matches, and the eval() method gets passed {{1, -1, -2}, {2, 3}} in list.
Context
This behavior is seen in the code. Currently, we omit the flat attribute for Union because of this behavior.
The actual pattern used is a little more complicated since it does not appear in the Union class but instead appears in the Abstract base class _SetOperation as:
"%(name)s[lists__, SameTest->sametest_]"