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: incorrect column reported for "struct literal does not implement" error #24689

Open
dhowden opened this issue Apr 4, 2018 · 4 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dhowden
Copy link
Contributor

dhowden commented Apr 4, 2018

Please answer these questions before submitting your issue. Thanks!

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

go1.10.1

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOOS="darwin"

What did you do?

https://play.golang.org/p/XjJFwvLoNoA

package main

type Interface interface {
	Method()
}

func UseInterface(i Interface) {}

type Struct struct{}

func main() {
	UseInterface(Struct{})
}

What did you expect to see?

prog.go:12:15: cannot use Struct literal (type Struct) as type Interface in argument to UseInterface:
	Struct does not implement Interface (missing Method method)
func main() {
	UseInterface(Struct{})
//	             ^
}

What did you see instead?

prog.go:12:21: cannot use Struct literal (type Struct) as type Interface in argument to UseInterface:
	Struct does not implement Interface (missing Method method)
func main() {
	UseInterface(Struct{})
//	                   ^
}
@dhowden
Copy link
Contributor Author

dhowden commented Apr 4, 2018

This is similar to #24339.

@bcmills bcmills added this to the Go1.11 milestone Apr 6, 2018
@bcmills bcmills added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 6, 2018
@bcmills
Copy link
Contributor

bcmills commented Apr 6, 2018

(CC @griesemer)

@griesemer
Copy link
Contributor

This is a reasonable request and it's not hard to fix for the specific case, but we'll run into the same problem again when it's a different expression. The problem is that we currently don't have the infrastructure to determine the exact source code range [beg, end[ for arbitrary expressions, only specific ones.

I'm inclined to postpone this for now, pending a future replacement of type checking done directly on the syntax tree.

@griesemer griesemer modified the milestones: Go1.11, Unplanned Apr 9, 2018
@griesemer
Copy link
Contributor

Part of #24780.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants