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

Comments

Projects
None yet
3 participants
@dhowden

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

This comment has been minimized.

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 label Apr 6, 2018

@bcmills

This comment has been minimized.

Member

bcmills commented Apr 6, 2018

(CC @griesemer)

@griesemer

This comment has been minimized.

Contributor

griesemer commented Apr 9, 2018

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

This comment has been minimized.

Contributor

griesemer commented Apr 9, 2018

Part of #24780.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment