Bug introduced in 10.1 and fixed in 11.0(.1)
In making an attempt to answer this question, we ran into a version-dependent pattern-matching issue. An extended discussion in the comments transpired, and some inconsistencies arose. Consider the following expressions:
MatchQ[f[a + 3, b + 3, c + 3], f[pat : (_ + n_) ..]]
MatchQ[f[a + 3, b + 3, c + 3], f[Verbatim[Plus][___, n_, ___] ..]]
On all of the machines and version I have access to, these expressions evaluate to True
, including
V10.0.1 under Mac OS 10.10.5
V 8.0 under Windows
7.0.1 under Windows
So far, in the following version-OS combinations, the expressions evaluate to False
:
10.4.0 / Win7-64
10.1.0 under Windows 7 x64
It seems as if something has changed between V10.0 and V10.1, and we'd like to pinpoint what it is.
It was noted that if the pattern is changed to
f[pat : (n_Integer + _) ..]
then the expression evaluates to True
.
This might be related to a similar issue outlined in Pattern does not match with Orderless head and answered by Mr. Wizard there, where it seems like the pattern-matching algorithm does not attempt to match every permutation of an expression inside a function (like Plus
) that has the Orderless
attribute, and that might be an issue here.
So what is going on, and what has changed?
Note 1
Since I cannot test to see which Pattern
s fail, anyone who can find a simpler example of the pattern that matches in earlier versions but doesn't in later versions should edit this post with those simpler patterns.