]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: emit error message for broken type
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 29 Aug 2019 17:42:38 +0000 (00:42 +0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 29 Aug 2019 19:08:00 +0000 (19:08 +0000)
The original report in #5172 was that cmd/compile was generating bogus
follow-on error messages when typechecking a struct failed. Instead of
fixing those follow-on error messages, golang.org/cl/9614044 suppress all
follow-on error messages after struct typecheck fails. We should
continue emitting error messages instead.

While at it, also add the test case for original report.

Fixes #33947

Change-Id: I4a5c6878977128abccd704350a12df743631c7bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/191944
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/typecheck.go
test/fixedbugs/issue5172.go

index 03c5528c3d1a2463d4aba892a2f19c0ab05a2189..b50f23da82f5baf1bc661c41388feddfc3cdf5a9 100644 (file)
@@ -503,12 +503,7 @@ func typecheck1(n *Node, top int) (res *Node) {
 
        case OTSTRUCT:
                ok |= Etype
-               t := tostruct(n.List.Slice())
-               if t.Broke() {
-                       n.Type = nil
-                       return n
-               }
-               setTypeNode(n, t)
+               setTypeNode(n, tostruct(n.List.Slice()))
                n.List.Set(nil)
 
        case OTINTER:
index a6acbd3db78923bdc239caa0f03152a5db4e5888..0339935b647ace031fd736763aa48f7e5305fe2b 100644 (file)
@@ -12,8 +12,15 @@ type foo struct {
        x bar // ERROR "undefined"
 }
 
+type T struct{}
+
+func (t T) Bar() {}
+
 func main() {
        var f foo
-       go f.bar()      // GCCGO_ERROR "undefined"
-       defer f.bar()   // GCCGO_ERROR "undefined"
+       go f.bar()    // ERROR "undefined"
+       defer f.bar() // ERROR "undefined"
+
+       t := T{1} // ERROR "too many values"
+       go t.Bar()
 }