]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: suppress duplicate type errors
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 4 May 2017 18:43:41 +0000 (11:43 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 4 May 2017 21:53:49 +0000 (21:53 +0000)
If we've already complained about a type T,
don't complain again about further expressions
involving it.

Fixes #20245 and hopefully all of its ilk.

Change-Id: Ic0abe8235d52e8a7ac40e3615aea8f3a54fd7cec
Reviewed-on: https://go-review.googlesource.com/42690
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/gc/typecheck.go
test/fixedbugs/issue11614.go
test/fixedbugs/issue20233.go
test/fixedbugs/issue20245.go [new file with mode: 0644]

index e66ce5dc985f88b68b28eba1c29346c16ced0b70..6f544a5b9aee43c32dcea7990d36db7654501d9a 100644 (file)
@@ -2156,7 +2156,9 @@ OpSwitch:
 
        evconst(n)
        if n.Op == OTYPE && top&Etype == 0 {
-               yyerror("type %v is not an expression", n.Type)
+               if !n.Type.Broke() {
+                       yyerror("type %v is not an expression", n.Type)
+               }
                n.Type = nil
                return n
        }
index 959643a51474425ef4a2c4c7a9ecda9943672615..91f134d44a9ab1f51a41196ba99dfbe54db0d6cf 100644 (file)
@@ -15,7 +15,7 @@ type I interface {
 }
 
 func n() {
-       (I) // ERROR "type I is not an expression"
+       (I)
 }
 
 func m() {
index 5734cf44ef08685135fee7bad7ebd762ad481d2a..4dec4e458beacd856385a723ef5be63f58fed243 100644 (file)
@@ -8,4 +8,4 @@
 
 package p
 
-var f = func(...A) // ERROR "type func(....*) is not an expression" ERROR "undefined: A"
+var f = func(...A) // ERROR "undefined: A"
diff --git a/test/fixedbugs/issue20245.go b/test/fixedbugs/issue20245.go
new file mode 100644 (file)
index 0000000..b07dbe2
--- /dev/null
@@ -0,0 +1,11 @@
+// errorcheck
+
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 20245: panic while formatting an error message
+
+package p
+
+var e = interface{ I1 } // ERROR "undefined: I1"