You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
prog.go:7:6: type T has both field and method named F
What did you see instead?
prog.go:7:6: type T has both field and method named F
prog.go:11:13: cannot call non-function t.F (type int)
I had this in a real program where there were many calls to t.F. Thus, half my screen was filled with that error, and I was very confused. It wasn't until I scrolled up and saw the first error that I realised what was going on.
I think the second error is redundant and confusing. t.F is ambiguous, so it's neither a func nor an integer. I think we should mark the field type as broken, and not report any errors because of its type.
A less invasive change would be to drop the (type int) or change it with (ambiguous type), but I'd prefer if we dropped the error altogether.
The text was updated successfully, but these errors were encountered:
mvdan
added
the
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
label
Oct 18, 2018
griesemer
added
NeedsFix
The path to resolution is known, but the work has not been done.
and removed
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
labels
Oct 18, 2018
My 2c: I think the fix here is to just suppress the errors at t.F's use. We should emit errors where users can fix errors, and there's nothing to be done at the use sites to fix a duplicate field/method declaration error: those need to be fixed at one of the declaration sites, which we're already emitting errors at.
Ambiguous selector errors are emitted at the selection site because they can be fixed there by further qualifying which (valid) selectable was intended. Whereas in this case, defining two fields/methods on the same type is invalid.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes - play link below.
What operating system and processor architecture are you using (
go env
)?Reproduces on the playground.
What did you do?
https://play.golang.org/p/vwhrdByyhFi
What did you expect to see?
What did you see instead?
I had this in a real program where there were many calls to
t.F
. Thus, half my screen was filled with that error, and I was very confused. It wasn't until I scrolled up and saw the first error that I realised what was going on.I think the second error is redundant and confusing.
t.F
is ambiguous, so it's neither a func nor an integer. I think we should mark the field type as broken, and not report any errors because of its type.A less invasive change would be to drop the
(type int)
or change it with(ambiguous type)
, but I'd prefer if we dropped the error altogether./cc @griesemer @odeke-em @mdempsky
The text was updated successfully, but these errors were encountered: