Skip to content

cmd/compile: confusing "cannot call non-function" error when a field is ambiguous #28268

@mvdan

Description

@mvdan

What version of Go are you using (go version)?

go version devel +8ccafb1ac7 Thu Oct 18 04:57:41 2018 +0000 linux/amd64

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?

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.

/cc @griesemer @odeke-em @mdempsky

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions