Skip to content

Commit d62c6c3

Browse files
committed
cmd/compile: suppress duplicate type errors
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent 39c07ce commit d62c6c3

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

src/cmd/compile/internal/gc/typecheck.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,9 @@ OpSwitch:
21562156

21572157
evconst(n)
21582158
if n.Op == OTYPE && top&Etype == 0 {
2159-
yyerror("type %v is not an expression", n.Type)
2159+
if !n.Type.Broke() {
2160+
yyerror("type %v is not an expression", n.Type)
2161+
}
21602162
n.Type = nil
21612163
return n
21622164
}

test/fixedbugs/issue11614.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type I interface {
1515
}
1616

1717
func n() {
18-
(I) // ERROR "type I is not an expression"
18+
(I)
1919
}
2020

2121
func m() {

test/fixedbugs/issue20233.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
package p
1010

11-
var f = func(...A) // ERROR "type func(....*) is not an expression" ERROR "undefined: A"
11+
var f = func(...A) // ERROR "undefined: A"

test/fixedbugs/issue20245.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// errorcheck
2+
3+
// Copyright 2017 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
// Issue 20245: panic while formatting an error message
8+
9+
package p
10+
11+
var e = interface{ I1 } // ERROR "undefined: I1"

0 commit comments

Comments
 (0)