1
0
mirror of https://github.com/golang/go synced 2024-11-14 13:20:30 -07:00
go/test/fixedbugs/issue28268.go
Robert Griesemer cc95d85fe4 cmd/compile: remove quoting in favor of clearer prose in error messages
In an attempt to address issue #65790 (confusing error messages),
quoting of names was introduced for some (but not all) names used
in error messages.

That CL solved the issue at hand at the cost of extra punctuation
(the quotes) plus some inconsistency (not all names were quoted).

This CL removes the quoting again in favor or adding a qualifying noun
(such as "name", "label", "package", "built-in" etc.) before a user-
specified name where needed.

For instance, instead of

        invalid argument to `max'

we now say

        invalid argument to built-in max

There's still a chance for confusion. For instance, before an error
might have been

        `sadly' not exported by package X

and now it would be

        name sadly not exported by package X

but adverbs (such as "sadly") seem unlikely names in programs.

This change touches a lot of files but only affects error messages.

Fixes #67685.

Change-Id: I95435b388f92cade316e2844d59ecf6953b178bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/589118
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2024-05-30 19:19:55 +00:00

31 lines
764 B
Go

// errorcheck
// Copyright 2018 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.
// Verify that follow-on errors due to conflicting
// struct field and method names are suppressed.
package p
type T struct {
a, b, c int
E
}
type E struct{}
func (T) b() {} // ERROR "field and method named b|redeclares struct field name|field and method with the same name b"
func (*T) E() {} // ERROR "field and method named E|redeclares struct field name|field and method with the same name E"
func _() {
var x T
_ = x.a
_ = x.b // no follow-on error here
x.b() // no follow-on error here
_ = x.c
_ = x.E // no follow-on error here
x.E() // no follow-on error here
}