1
0
mirror of https://github.com/golang/go synced 2024-11-24 11:00:08 -07:00

go/types, types2: better error message for blank interface method name (cleanup)

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>
This commit is contained in:
Robert Griesemer 2022-03-28 15:42:30 -07:00
parent 9038c24498
commit f71daa6fe6
4 changed files with 6 additions and 10 deletions

View 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 _")
}
continue // ignore
}

View 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()
}

View 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
}

View 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()
}