mirror of
https://github.com/golang/go
synced 2024-11-24 10:40:10 -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:
parent
9038c24498
commit
f71daa6fe6
@ -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
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
4
src/go/types/testdata/check/decls0.go
vendored
4
src/go/types/testdata/check/decls0.go
vendored
@ -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()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user