Commit ca8ec69c authored by Robert Griesemer's avatar Robert Griesemer

go/types: don't report errors referring to invalid types or operands

Such errors are likely spurious and caused by previously reported
errors; they don't add valuable information. Simply drop them.

Fixes #24182.

Change-Id: I0ac48c41647c628aa7636b29eaedfd9d01913762
Reviewed-on: https://go-review.googlesource.com/116735Reviewed-by: 's avatarAlan Donovan <adonovan@google.com>
parent 9e4c344c
......@@ -67,10 +67,20 @@ func (check *Checker) dump(format string, args ...interface{}) {
}
func (check *Checker) err(pos token.Pos, msg string, soft bool) {
// Cheap trick: Don't report errors with messages containing
// "invalid operand" or "invalid type" as those tend to be
// follow-on errors which don't add useful information. Only
// exclude them if these strings are not at the beginning,
// and only if we have at least one error already reported.
if check.firstErr != nil && (strings.Index(msg, "invalid operand") > 0 || strings.Index(msg, "invalid type") > 0) {
return
}
err := Error{check.fset, pos, msg, soft}
if check.firstErr == nil {
check.firstErr = err
}
f := check.conf.Error
if f == nil {
panic(bailout{}) // report only first error
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment