mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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
Change-Id: Idd519c6841167f932899b0ada347fb90a38a765e
GitHub-Last-Rev: 6f43cbca63
GitHub-Pull-Request: golang/go#66165
Reviewed-on: https://go-review.googlesource.com/c/go/+/569735
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
b1e933d955
commit
3aa1b00081
2 changed files with 3 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue