Skip to content

Commit

Permalink
go/ast/astutil: update Equal to handle new ast.IndexListExpr type
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikh committed Mar 28, 2022
1 parent 27f1505 commit 11e5f96
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions go/ast/astutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,17 @@ func Equal(a, b ast.Node) bool {
case *ast.IndexExpr:
b := b.(*ast.IndexExpr)
return Equal(a.X, b.X) && Equal(a.Index, b.Index)
case *ast.IndexListExpr:
b := b.(*ast.IndexListExpr)
if len(a.Indices) != len(b.Indices) {
return false
}
for i, v := range a.Indices {
if !Equal(v, b.Indices[i]) {
return false
}
}
return Equal(a.X, b.X)
case *ast.KeyValueExpr:
b := b.(*ast.KeyValueExpr)
return Equal(a.Key, b.Key) && Equal(a.Value, b.Value)
Expand Down

0 comments on commit 11e5f96

Please sign in to comment.