mirror of
https://github.com/golang/go
synced 2024-11-21 11:44:43 -07:00
regexp: fix compiling alternate patterns of different fold case literals
Fixing Equal method in regexp/syntax package fixes compilation of some alternate patterns like "0A|0[aA]". Fixes #59007
This commit is contained in:
parent
6dc99aa7eb
commit
83e6d1d06c
@ -98,6 +98,8 @@ var findTests = []FindTest{
|
||||
{`\B`, "x y", nil},
|
||||
{`\B`, "xx yy", build(2, 1, 1, 4, 4)},
|
||||
{`(|a)*`, "aa", build(3, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2)},
|
||||
{`0A|0[aA]`, "0a", build(1, 0, 2)},
|
||||
{`0[aA]|0A`, "0a", build(1, 0, 2)},
|
||||
|
||||
// RE2 tests
|
||||
{`[^\S\s]`, "abcd", nil},
|
||||
|
@ -76,7 +76,7 @@ func (x *Regexp) Equal(y *Regexp) bool {
|
||||
}
|
||||
|
||||
case OpLiteral, OpCharClass:
|
||||
return slices.Equal(x.Rune, y.Rune)
|
||||
return x.Flags&FoldCase == y.Flags&FoldCase && slices.Equal(x.Rune, y.Rune)
|
||||
|
||||
case OpAlternate, OpConcat:
|
||||
return slices.EqualFunc(x.Sub, y.Sub, (*Regexp).Equal)
|
||||
|
Loading…
Reference in New Issue
Block a user