]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: better error message for blank interface method name (cleanup)
authorRobert Griesemer <gri@golang.org>
Mon, 28 Mar 2022 22:42:30 +0000 (15:42 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 29 Mar 2022 17:21:21 +0000 (17:21 +0000)
Use the 1.17 compiler error message.

Change-Id: Ic62de5bfc9681674069934afc590f5840729f8e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/396297
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/interface.go
src/cmd/compile/internal/types2/testdata/check/decls0.go
src/go/types/interface.go
src/go/types/testdata/check/decls0.go

index b8bf88dc624d18daf4addf6bad2fe9c0ef4db39e..431b91f270c759bdd4224db12a0c06cba573164a 100644 (file)
@@ -132,11 +132,7 @@ func (check *Checker) interfaceType(ityp *Interface, iface *syntax.InterfaceType
                // We have a method with name f.Name.
                name := f.Name.Value
                if name == "_" {
-                       if check.conf.CompilerErrorMessages {
-                               check.error(f.Name, "methods must have a unique non-blank name")
-                       } else {
-                               check.error(f.Name, "invalid method name _")
-                       }
+                       check.error(f.Name, "methods must have a unique non-blank name")
                        continue // ignore
                }
 
index aa98480b994ee9d1fc31191c0f2208f4d78a9596..927c2d353de0daad06c6378c8152340472c458a4 100644 (file)
@@ -194,8 +194,8 @@ func (S0) m4() (x *S0 /* ERROR illegal cycle in method declaration */ .m4) { ret
 
 // interfaces may not have any blank methods
 type BlankI interface {
-       _ /* ERROR "invalid method name" */ ()
-       _ /* ERROR "invalid method name" */ (float32) int
+       _ /* ERROR "methods must have a unique non-blank name" */ ()
+       _ /* ERROR "methods must have a unique non-blank name" */ (float32) int
        m()
 }
 
index 361ef7eddf6919c327253ce2091e1c62f11a989d..52ae123bb7bf5ecd35cbd7feaec0dfd426a454b1 100644 (file)
@@ -173,7 +173,7 @@ func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, d
                // We have a method with name f.Names[0].
                name := f.Names[0]
                if name.Name == "_" {
-                       check.errorf(name, _BlankIfaceMethod, "invalid method name _")
+                       check.errorf(name, _BlankIfaceMethod, "methods must have a unique non-blank name")
                        continue // ignore
                }
 
index 740c9b4fdf612bb85df782c87f2b486ac59bf342..d8fcef0824d402588bd46d4ea24f6abd290b43c8 100644 (file)
@@ -196,8 +196,8 @@ func (S0) m4 () (x *S0 /* ERROR illegal cycle in method declaration */ .m4) { re
 
 // interfaces may not have any blank methods
 type BlankI interface {
-       _ /* ERROR "invalid method name" */ ()
-       _ /* ERROR "invalid method name" */ (float32) int
+       _ /* ERROR "methods must have a unique non-blank name" */ ()
+       _ /* ERROR "methods must have a unique non-blank name" */ (float32) int
        m()
 }