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: "<T> literal" in error messages for type literals that don't type check #17645

Closed
dominikh opened this issue Oct 28, 2016 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dominikh
Copy link
Member

Please answer these questions before submitting your issue. Thanks!

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

go version go1.7.3 linux/amd64
go version devel +b679665 Fri Oct 28 07:58:47 2016 +0000 linux/amd64

What did you do?

https://play.golang.org/p/gGiuxRMO-h

What did you expect to see?

main.go:9: cannot use "" (type string) as type int in field value
main.go:9: cannot use append(s, Foo literal) (type []int) as type string in assignment

What did you see instead?

main.go:9: cannot use "" (type string) as type int in field value
main.go:9: cannot use append(s, <T> literal) (type []int) as type string in assignment
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 28, 2016
@quentinmit quentinmit added this to the Go1.8Maybe milestone Oct 28, 2016
@JayNakrani
Copy link
Contributor

JayNakrani commented Oct 29, 2016

It should give three errors.

main.go:9: cannot use "" (type string) as type int in field value
main.go:9: cannot use Foo literal (type Foo) as type int in append
main.go:9: cannot use append(s, Foo literal) (type []int) as type string in assignment

Root cause: typecheckcomplit() nils out the n.Type upon finding new errors. That hides new errors in children node as well as the type info of current node. Sending out the fix.

@JayNakrani
Copy link
Contributor

After golang.org/cl/32324 :

$ ./pkg/tool/linux_amd64/compile /tmp/test/main.go 
/tmp/test/main.go:9: cannot use "" (type string) as type int in field value
/tmp/test/main.go:9: cannot use Foo literal (type Foo) as type int in append
/tmp/test/main.go:9: cannot use append(s, Foo literal) (type []int) as type string in assignment

@gopherbot
Copy link

CL https://golang.org/cl/32324 mentions this issue.

@golang golang locked and limited conversation to collaborators Dec 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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