Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: missing T.m is a field, not a method error upon assignments to interfaces #51025

Closed
griesemer opened this issue Feb 5, 2022 · 2 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@griesemer
Copy link
Contributor

The 1.17 compiler did report this extra error. See fixedbugs/bug231.go for a test case.

package main

type I interface{ m() }
type T struct{ m func() }
type M struct{}

func (M) m() {}

func main() {
	var t T
	var m M
	var i I

	i = m
	// types2 does not give extra error "T.m is a field, not a method"
	i = t // ERROR "not a method|has no methods|does not implement I"
	_ = i
}

cc: @findleyr

@griesemer griesemer added the NeedsFix The path to resolution is known, but the work has not been done. label Feb 5, 2022
@griesemer griesemer added this to the Go1.19 milestone Feb 5, 2022
@griesemer griesemer self-assigned this Feb 5, 2022
@griesemer
Copy link
Contributor Author

This requires a bit of consolidation and clean-up around method/field lookups and error reporting. Moving forward.

@griesemer griesemer modified the milestones: Go1.19, Go1.20 Jun 24, 2022
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
@gopherbot
Copy link

Change https://go.dev/cl/438856 mentions this issue: go/types, types2: better error if there's a field with the name of a missing method

romaindoumenc pushed a commit to TroutSoftware/go that referenced this issue Nov 3, 2022
…missing method

Fixes golang#51025.

Change-Id: I469a705e7da059e7ac0b12b05beb9ed5d3617396
Reviewed-on: https://go-review.googlesource.com/c/go/+/438856
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
@golang golang locked and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
Development

No branches or pull requests

2 participants