mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
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 <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
39c07ce9e5
commit
d62c6c3c39
|
@ -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
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ type I interface {
|
|||
}
|
||||
|
||||
func n() {
|
||||
(I) // ERROR "type I is not an expression"
|
||||
(I)
|
||||
}
|
||||
|
||||
func m() {
|
||||
|
|
|
@ -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"
|
||||
|
|
11
test/fixedbugs/issue20245.go
Normal file
11
test/fixedbugs/issue20245.go
Normal file
|
@ -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"
|
Loading…
Reference in a new issue