]> Cypherpunks.ru repositories - gostls13.git/commitdiff
go/ast: rename MultiIndexExpr to IndexListExpr
authorRobert Findley <rfindley@google.com>
Wed, 8 Sep 2021 19:51:10 +0000 (15:51 -0400)
committerRobert Findley <rfindley@google.com>
Wed, 8 Sep 2021 20:14:03 +0000 (20:14 +0000)
As discussed in #47781, IndexListExpr is one character shorter and has
the advantage of being next to IndexExpr in documentation.

Updates #47781

Change-Id: I709d5c1a79b4f9aebcd6445e4ab0cd6dae45bab7
Reviewed-on: https://go-review.googlesource.com/c/go/+/348609
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

12 files changed:
src/go/ast/ast.go
src/go/ast/walk.go
src/go/internal/typeparams/typeparams.go
src/go/parser/parser.go
src/go/printer/nodes.go
src/go/types/call.go
src/go/types/expr.go
src/go/types/exprstring.go
src/go/types/resolver.go
src/go/types/signature.go
src/go/types/struct.go
src/go/types/typexpr.go

index f9223e4f91afa114383cb665c275198f501fea56..70d0912f6789775721015b73e4d0a791b1c6f24f 100644 (file)
@@ -344,9 +344,9 @@ type (
                Rbrack token.Pos // position of "]"
        }
 
-       // A MultiIndexExpr node represents an expression followed by multiple
+       // An IndexListExpr node represents an expression followed by multiple
        // indices.
-       MultiIndexExpr struct {
+       IndexListExpr struct {
                X       Expr      // expression
                Lbrack  token.Pos // position of "["
                Indices []Expr    // index expressions
@@ -496,7 +496,7 @@ func (x *CompositeLit) Pos() token.Pos {
 func (x *ParenExpr) Pos() token.Pos      { return x.Lparen }
 func (x *SelectorExpr) Pos() token.Pos   { return x.X.Pos() }
 func (x *IndexExpr) Pos() token.Pos      { return x.X.Pos() }
-func (x *MultiIndexExpr) Pos() token.Pos { return x.X.Pos() }
+func (x *IndexListExpr) Pos() token.Pos  { return x.X.Pos() }
 func (x *SliceExpr) Pos() token.Pos      { return x.X.Pos() }
 func (x *TypeAssertExpr) Pos() token.Pos { return x.X.Pos() }
 func (x *CallExpr) Pos() token.Pos       { return x.Fun.Pos() }
@@ -530,7 +530,7 @@ func (x *CompositeLit) End() token.Pos   { return x.Rbrace + 1 }
 func (x *ParenExpr) End() token.Pos      { return x.Rparen + 1 }
 func (x *SelectorExpr) End() token.Pos   { return x.Sel.End() }
 func (x *IndexExpr) End() token.Pos      { return x.Rbrack + 1 }
-func (x *MultiIndexExpr) End() token.Pos { return x.Rbrack + 1 }
+func (x *IndexListExpr) End() token.Pos  { return x.Rbrack + 1 }
 func (x *SliceExpr) End() token.Pos      { return x.Rbrack + 1 }
 func (x *TypeAssertExpr) End() token.Pos { return x.Rparen + 1 }
 func (x *CallExpr) End() token.Pos       { return x.Rparen + 1 }
@@ -562,7 +562,7 @@ func (*CompositeLit) exprNode()   {}
 func (*ParenExpr) exprNode()      {}
 func (*SelectorExpr) exprNode()   {}
 func (*IndexExpr) exprNode()      {}
-func (*MultiIndexExpr) exprNode() {}
+func (*IndexListExpr) exprNode()  {}
 func (*SliceExpr) exprNode()      {}
 func (*TypeAssertExpr) exprNode() {}
 func (*CallExpr) exprNode()       {}
index 530735e76f068afe62e029c713e4602d9af7ab09..308662f633b50cec49ec14e355f98c4aa24bbded 100644 (file)
@@ -116,7 +116,7 @@ func Walk(v Visitor, node Node) {
                Walk(v, n.X)
                Walk(v, n.Index)
 
-       case *MultiIndexExpr:
+       case *IndexListExpr:
                Walk(v, n.X)
                for _, index := range n.Indices {
                        Walk(v, index)
index 9bf4f7bf97c67560a304e55a11bc0eb14ad35248..3f84f2f0d05afd28b9d10b8b146e09deee2ef505 100644 (file)
@@ -21,7 +21,7 @@ func PackIndexExpr(x ast.Expr, lbrack token.Pos, exprs []ast.Expr, rbrack token.
                        Rbrack: rbrack,
                }
        default:
-               return &ast.MultiIndexExpr{
+               return &ast.IndexListExpr{
                        X:       x,
                        Lbrack:  lbrack,
                        Indices: exprs,
@@ -30,25 +30,24 @@ func PackIndexExpr(x ast.Expr, lbrack token.Pos, exprs []ast.Expr, rbrack token.
        }
 }
 
-// IndexExpr wraps an ast.IndexExpr or ast.MultiIndexExpr into the
-// MultiIndexExpr interface.
+// IndexExpr wraps an ast.IndexExpr or ast.IndexListExpr.
 //
 // Orig holds the original ast.Expr from which this IndexExpr was derived.
 type IndexExpr struct {
-       Orig ast.Expr // the wrapped expr, which may be distinct from MultiIndexExpr below.
-       *ast.MultiIndexExpr
+       Orig ast.Expr // the wrapped expr, which may be distinct from the IndexListExpr below.
+       *ast.IndexListExpr
 }
 
 func UnpackIndexExpr(n ast.Node) *IndexExpr {
        switch e := n.(type) {
        case *ast.IndexExpr:
-               return &IndexExpr{e, &ast.MultiIndexExpr{
+               return &IndexExpr{e, &ast.IndexListExpr{
                        X:       e.X,
                        Lbrack:  e.Lbrack,
                        Indices: []ast.Expr{e.Index},
                        Rbrack:  e.Rbrack,
                }}
-       case *ast.MultiIndexExpr:
+       case *ast.IndexListExpr:
                return &IndexExpr{e, e}
        }
        return nil
index 5c0af8d3b835d4f7f86c77e4073b46939cd8855b..049515656c79020c676da5088101f23d592ff8a6 100644 (file)
@@ -1570,7 +1570,7 @@ func (p *parser) checkExpr(x ast.Expr) ast.Expr {
                panic("unreachable")
        case *ast.SelectorExpr:
        case *ast.IndexExpr:
-       case *ast.MultiIndexExpr:
+       case *ast.IndexListExpr:
        case *ast.SliceExpr:
        case *ast.TypeAssertExpr:
                // If t.Type == nil we have a type assertion of the form
@@ -1660,7 +1660,7 @@ func (p *parser) parsePrimaryExpr() (x ast.Expr) {
                                        return
                                }
                                // x is possibly a composite literal type
-                       case *ast.IndexExpr, *ast.MultiIndexExpr:
+                       case *ast.IndexExpr, *ast.IndexListExpr:
                                if p.exprLev < 0 {
                                        return
                                }
index 9ce011542655db901b9fa88933504fe9e833a236..053a8ef174a9c8e2f99724f19f98fd131733d005 100644 (file)
@@ -873,7 +873,7 @@ func (p *printer) expr1(expr ast.Expr, prec1, depth int) {
                p.expr0(x.Index, depth+1)
                p.print(x.Rbrack, token.RBRACK)
 
-       case *ast.MultiIndexExpr:
+       case *ast.IndexListExpr:
                // TODO(gri): as for IndexExpr, should treat [] like parentheses and undo
                // one level of depth
                p.expr1(x.X, token.HighestPrec, 1)
index 39cd67c5f3ecb7b237f812a6e03828e7f756f6dd..3710756c29c24cb64a5878cb5d89c171520eabd1 100644 (file)
@@ -337,7 +337,7 @@ func (check *Checker) arguments(call *ast.CallExpr, sig *Signature, targs []Type
        if sig.TypeParams().Len() > 0 {
                if !check.allowVersion(check.pkg, 1, 18) {
                        switch call.Fun.(type) {
-                       case *ast.IndexExpr, *ast.MultiIndexExpr:
+                       case *ast.IndexExpr, *ast.IndexListExpr:
                                ix := typeparams.UnpackIndexExpr(call.Fun)
                                check.softErrorf(inNode(call.Fun, ix.Lbrack), _Todo, "function instantiation requires go1.18 or later")
                        default:
index 5ca4edebcb90f49793769988599b75eec88ad2a3..007205a9fb4145bf7ed1bf90c79ede3669cbddbf 100644 (file)
@@ -1392,7 +1392,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind {
        case *ast.SelectorExpr:
                check.selector(x, e)
 
-       case *ast.IndexExpr, *ast.MultiIndexExpr:
+       case *ast.IndexExpr, *ast.IndexListExpr:
                ix := typeparams.UnpackIndexExpr(e)
                if check.indexExpr(x, ix) {
                        check.funcInst(x, ix)
index aee8a5ba5f74d2826d76ddbbf41ade0992cdeebd..06e7a9dcb4435ed529e953e6fd944bb596cc2f3c 100644 (file)
@@ -67,7 +67,7 @@ func WriteExpr(buf *bytes.Buffer, x ast.Expr) {
                buf.WriteByte('.')
                buf.WriteString(x.Sel.Name)
 
-       case *ast.IndexExpr, *ast.MultiIndexExpr:
+       case *ast.IndexExpr, *ast.IndexListExpr:
                ix := typeparams.UnpackIndexExpr(x)
                WriteExpr(buf, ix.X)
                buf.WriteByte('[')
index b04a673ab7e98d8b7a5011e38503fb60fccd74c1..486c09220b675af19a839a8deabce0876a67093f 100644 (file)
@@ -513,7 +513,7 @@ L: // unpack receiver type
 
        // unpack type parameters, if any
        switch rtyp.(type) {
-       case *ast.IndexExpr, *ast.MultiIndexExpr:
+       case *ast.IndexExpr, *ast.IndexListExpr:
                ix := typeparams.UnpackIndexExpr(rtyp)
                rtyp = ix.X
                if unpackParams {
index 05619479019ac8a17f52c452da194bb164a76205..88ea07d5d34263cb00952bae321e0f96e420331a 100644 (file)
@@ -326,7 +326,7 @@ func isubst(x ast.Expr, smap map[*ast.Ident]*ast.Ident) ast.Expr {
                        new.X = X
                        return &new
                }
-       case *ast.IndexExpr, *ast.MultiIndexExpr:
+       case *ast.IndexExpr, *ast.IndexListExpr:
                ix := typeparams.UnpackIndexExpr(x)
                var newIndexes []ast.Expr
                for i, index := range ix.Indices {
index f6e6f2a5e653f1db3dcac8af19db164e0933aef0..24a2435ff7d3f05ac0a4f27758dde89202cdcfcb 100644 (file)
@@ -176,7 +176,7 @@ func embeddedFieldIdent(e ast.Expr) *ast.Ident {
                return e.Sel
        case *ast.IndexExpr:
                return embeddedFieldIdent(e.X)
-       case *ast.MultiIndexExpr:
+       case *ast.IndexListExpr:
                return embeddedFieldIdent(e.X)
        }
        return nil // invalid embedded field
index af5629714429d4bebd72cf1944bddaede2b2fdc1..6b4a3538b610b0688c98294f2e5207210af0c1cb 100644 (file)
@@ -258,7 +258,7 @@ func (check *Checker) typInternal(e0 ast.Expr, def *Named) (T Type) {
                        check.errorf(&x, _NotAType, "%s is not a type", &x)
                }
 
-       case *ast.IndexExpr, *ast.MultiIndexExpr:
+       case *ast.IndexExpr, *ast.IndexListExpr:
                ix := typeparams.UnpackIndexExpr(e)
                if !check.allowVersion(check.pkg, 1, 18) {
                        check.softErrorf(inNode(e, ix.Lbrack), _Todo, "type instantiation requires go1.18 or later")