Take for example
head[b_[PatternSequence[_, _]]] := 9
I know this example serves no purpose as is. It also happens in useful examples such as
head[b_[_, arg : PatternSequence[_, _]]] := {arg, b}
The definition is made propely, but it issues the message
Pattern::patvar:
First element in patternPattern[1,_]
is not a valid pattern name. >>
A simpler example of the problem, suggested by @celtschk in comments
b_[PatternSequence[_, _]] :> 0
and
b_[PatternSequence[]] :> 0
Particularly interesting is an example @OleksandrR found, in which the mysterious numbering of patterns becomes more evident
(p : {a_, b_, c_})[PatternSequence[]] -> Null
Pattern::patvar:
"First element in patternPattern[4,{Pattern[1,_],Pattern[2,_],Pattern[3,_]}]
is not a valid pattern name."
x /. b_[PatternSequence[_, _]] :> 0
— note the absence ofhead
. It happens neither forb[PatternSequence[_,_]]
nor forb_[_,_]
, so obviously it is triggered when a pattern as head is combined with aPatternSequence
in the corresponding argument list. $\endgroup$ – celtschk May 21 '12 at 22:48b
it works fine $\endgroup$ – Rojo May 21 '12 at 22:51PatternSequence
.b_[PatternSequence[_]]
doesn't trigger the message, nor doesb_[PatternSequence[__]]
, but bothb_[PatternSequence[_, _, _]]
andb_[PatternSequence[]]
do. Also, applying the replacement rule isn't necessary; already using the pattern inb_[PatternSequence[]] :> 0
triggers the mesage (however just writing the pattern without the:> 0
doesn't). $\endgroup$ – celtschk May 21 '12 at 22:57