From b94346e69bb01e1cd522ddfa9d09f41d9d4d3e98 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 26 Nov 2020 12:26:02 -0800 Subject: test: match gofrontend error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These changes match the following gofrontend error messages: blank1.go:16:1: error: may not define methods on non-local type chan/perm.go:28:9: error: expected channel chan/perm.go:29:11: error: left operand of ‘<-’ must be channel chan/perm.go:69:9: error: argument must be channel complit1.go:25:16: error: attempt to slice object that is not array, slice, or string complit1.go:26:16: error: attempt to slice object that is not array, slice, or string complit1.go:27:17: error: attempt to slice object that is not array, slice, or string complit1.go:49:41: error: may only omit types within composite literals of slice, array, or map type complit1.go:50:14: error: expected struct, slice, array, or map type for composite literal convlit.go:24:9: error: invalid type conversion (cannot use type unsafe.Pointer as type string) convlit.go:25:9: error: invalid type conversion (cannot use type unsafe.Pointer as type float64) convlit.go:26:9: error: invalid type conversion (cannot use type unsafe.Pointer as type int) ddd1.go:63:9: error: invalid use of ‘...’ calling non-variadic function fixedbugs/bug176.go:12:18: error: index expression is not integer constant fixedbugs/bug332.go:17:10: error: use of undefined type ‘T’ fixedbugs/issue4232.go:22:16: error: integer constant overflow fixedbugs/issue4232.go:33:16: error: integer constant overflow fixedbugs/issue4232.go:44:25: error: integer constant overflow fixedbugs/issue4232.go:55:16: error: integer constant overflow fixedbugs/issue4458.go:19:14: error: type has no method ‘foo’ fixedbugs/issue5172.go:24:14: error: too many expressions for struct init.go:17:9: error: reference to undefined name ‘runtime’ initializerr.go:26:29: error: duplicate value for index 1 interface/explicit.go:60:14: error: type assertion only valid for interface types label.go:64:9: error: reference to undefined label ‘go2’ label1.go:18:97: error: continue statement not within for label1.go:22:97: error: continue statement not within for label1.go:106:89: error: continue statement not within for label1.go:108:26: error: invalid continue label ‘on’ label1.go:111:118: error: break statement not within for or switch or select label1.go:113:23: error: invalid break label ‘dance’ map1.go:64:9: error: not enough arguments map1.go:65:9: error: not enough arguments map1.go:67:9: error: argument 1 must be a map method2.go:36:11: error: reference to undefined field or method ‘val’ method2.go:37:11: error: reference to undefined field or method ‘val’ method2.go:41:12: error: method requires pointer (use ‘(*T).g’) syntax/chan1.go:13:19: error: send statement used as value; use select for non-blocking send syntax/chan1.go:17:11: error: send statement used as value; use select for non-blocking send Change-Id: I98047b60a376e3d2788836300f7fcac3f2c285cb Reviewed-on: https://go-review.googlesource.com/c/go/+/273527 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Cherry Zhang --- test/interface/explicit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/interface/explicit.go') diff --git a/test/interface/explicit.go b/test/interface/explicit.go index 1fb3b6a05a..3f9451e8d2 100644 --- a/test/interface/explicit.go +++ b/test/interface/explicit.go @@ -57,7 +57,7 @@ func main() { // cannot type-assert non-interfaces f := 2.0 - _ = f.(int) // ERROR "non-interface type" + _ = f.(int) // ERROR "non-interface type|only valid for interface types" } -- cgit v1.3-5-g9baa From d90b199e9c3d6673b1951ddb6a78addd7e0dda26 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Thu, 3 Dec 2020 14:00:19 -0800 Subject: [dev.regabi] cmd/compile: silence errors about missing blank methods If an interface contains a blank method, that's already an error. No need for useless follow-up error messages about not implementing them. Fixes #42964. Change-Id: I5bf53a8f27d75d4c86c61588c5e2e3e95563d320 Reviewed-on: https://go-review.googlesource.com/c/go/+/275294 Trust: Matthew Dempsky Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/gc/dcl.go | 12 ------------ src/cmd/compile/internal/gc/noder.go | 5 ++++- test/interface/explicit.go | 7 ++++--- 3 files changed, 8 insertions(+), 16 deletions(-) (limited to 'test/interface/explicit.go') diff --git a/src/cmd/compile/internal/gc/dcl.go b/src/cmd/compile/internal/gc/dcl.go index 5936aeb950..a77c1aed45 100644 --- a/src/cmd/compile/internal/gc/dcl.go +++ b/src/cmd/compile/internal/gc/dcl.go @@ -317,18 +317,6 @@ func colasdefn(left []ir.Node, defn ir.Node) { } } -// declare the arguments in an -// interface field declaration. -func ifacedcl(n *ir.Field) { - if n.Sym == nil { - base.Fatalf("ifacedcl") - } - - if n.Sym.IsBlank() { - base.Errorf("methods must have a unique non-blank name") - } -} - // declare the function proper // and declare the arguments. // called in extern-declaration context diff --git a/src/cmd/compile/internal/gc/noder.go b/src/cmd/compile/internal/gc/noder.go index 61320123a8..1cd8375677 100644 --- a/src/cmd/compile/internal/gc/noder.go +++ b/src/cmd/compile/internal/gc/noder.go @@ -899,10 +899,13 @@ func (p *noder) interfaceType(expr *syntax.InterfaceType) ir.Node { n = ir.NewField(p.pos(method), nil, importName(p.packname(method.Type)).(ir.Ntype), nil) } else { mname := p.name(method.Name) + if mname.IsBlank() { + base.Errorf("methods must have a unique non-blank name") + continue + } sig := p.typeExpr(method.Type).(*ir.FuncType) sig.Recv = fakeRecv() n = ir.NewField(p.pos(method), mname, sig, nil) - ifacedcl(n) } l = append(l, n) } diff --git a/test/interface/explicit.go b/test/interface/explicit.go index 3f9451e8d2..b705b97676 100644 --- a/test/interface/explicit.go +++ b/test/interface/explicit.go @@ -100,6 +100,7 @@ type T2 struct{} func (t *T2) M() {} func (t *T2) _() {} -// Check that nothing satisfies an interface with blank methods. -var b1 B1 = &T2{} // ERROR "incompatible|missing _ method" -var b2 B2 = &T2{} // ERROR "incompatible|missing _ method" +// Already reported about the invalid blank interface method above; +// no need to report about not implementing it. +var b1 B1 = &T2{} +var b2 B2 = &T2{} -- cgit v1.3-5-g9baa