]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: generate literals.go from corresponding types2 source
authorRobert Griesemer <gri@golang.org>
Wed, 4 Sep 2024 23:37:45 +0000 (16:37 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 5 Sep 2024 22:09:24 +0000 (22:09 +0000)
Change-Id: I0635101b984725ee24c2207ebfdb413d29212b67
Reviewed-on: https://go-review.googlesource.com/c/go/+/610558
Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/go/types/generate_test.go
src/go/types/literals.go

index de2e63d163bf2e4dde90a07ca7dd29596f9e01cb..1422d1ae7c5e931529ccf1fb1955b86091e5c42a 100644 (file)
@@ -136,9 +136,15 @@ var filemap = map[string]action{
        // "initorder.go": fixErrErrorfCall, // disabled for now due to unresolved error_ use implications for gopls
        "instantiate.go":      func(f *ast.File) { fixTokenPos(f); fixCheckErrorfCall(f) },
        "instantiate_test.go": func(f *ast.File) { renameImportPath(f, `"cmd/compile/internal/types2"->"go/types"`) },
-       "lookup.go":           func(f *ast.File) { fixTokenPos(f) },
-       "main_test.go":        nil,
-       "map.go":              nil,
+       "literals.go": func(f *ast.File) {
+               renameImportPath(f, `"cmd/compile/internal/syntax"->"go/ast"`)
+               renameSelectorExprs(f, "syntax.Name->ast.Ident", "key.Value->key.Name", "atyp.Elem->atyp.Elt") // must happen before renaming identifiers
+               renameIdents(f, "syntax->ast")
+               renameSelectors(f, "ElemList->Elts")
+       },
+       "lookup.go":    func(f *ast.File) { fixTokenPos(f) },
+       "main_test.go": nil,
+       "map.go":       nil,
        "mono.go": func(f *ast.File) {
                fixTokenPos(f)
                insertImportPath(f, `"go/ast"`)
index d2bd7b5d15c5a1391af443f47547e39c433a90a2..a32f8ca37cb7e802ce3e5263270a7c6bfdff7c06 100644 (file)
@@ -1,3 +1,6 @@
+// Code generated by "go test -run=Generate -write=all"; DO NOT EDIT.
+// Source: ../../cmd/compile/internal/types2/literals.go
+
 // Copyright 2024 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
@@ -81,7 +84,7 @@ func (check *Checker) compositeLit(T *target, x *operand, e *ast.CompositeLit, h
                                        check.errorf(kv, InvalidLitField, "invalid field name %s in struct literal", kv.Key)
                                        continue
                                }
-                               i := fieldIndex(utyp.fields, check.pkg, key.Name, false)
+                               i := fieldIndex(fields, check.pkg, key.Name, false)
                                if i < 0 {
                                        var alt Object
                                        if j := fieldIndex(fields, check.pkg, key.Name, true); j >= 0 {
@@ -117,9 +120,7 @@ func (check *Checker) compositeLit(T *target, x *operand, e *ast.CompositeLit, h
                                // i < len(fields)
                                fld := fields[i]
                                if !fld.Exported() && fld.pkg != check.pkg {
-                                       check.errorf(x,
-                                               UnexportedLitField,
-                                               "implicit assignment to unexported field %s in struct literal of type %s", fld.name, base)
+                                       check.errorf(x, UnexportedLitField, "implicit assignment to unexported field %s in struct literal of type %s", fld.name, base)
                                        continue
                                }
                                etyp := fld.typ