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: duplicate error on int("1") bad cast #20812

Closed
ALTree opened this issue Jun 27, 2017 · 5 comments
Closed

cmd/compile: duplicate error on int("1") bad cast #20812

ALTree opened this issue Jun 27, 2017 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ALTree
Copy link
Member

ALTree commented Jun 27, 2017

$ gotip version
go version devel +b4dd1d965d Sun Jun 25 15:57:18 2017 +0000 linux/amd64

The following

package p

var _ = int("1")

prints (in go1.6, go1.7, go1.8 and go1.9beta2)

./prova.go:3:12: cannot convert "1" to type int
./prova.go:3:12: cannot convert "1" (type string) to type int

Printing the same error message two times is unnecessary. Note that []int("a") (and variations) only print one.

@ALTree ALTree added this to the Go1.10 milestone Jun 27, 2017
@ALTree ALTree added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 27, 2017
@kashav
Copy link
Contributor

kashav commented Jun 27, 2017

Can I have a go at this?

@bradfitz
Copy link
Contributor

@kshvmdn, always. No need to ask.

@kashav
Copy link
Contributor

kashav commented Jun 27, 2017

@bradfitz cool, thanks!

@ALTree for the record, this is effecting more than just int casts (re: issue title):

func main() {
	var _ = bool(0)
	var _ = bool("false")
	var _ = int(false)
	var _ = string(true)
}
$ go run main.go
./main.go:4: cannot convert 0 to type bool
./main.go:4: cannot convert 0 (type int) to type bool
./main.go:5: cannot convert "false" to type bool
./main.go:5: cannot convert "false" (type string) to type bool
./main.go:6: cannot convert false to type int
./main.go:6: cannot convert false (type bool) to type int
./main.go:7: cannot convert true to type string
./main.go:7: cannot convert true (type bool) to type string

@gopherbot
Copy link

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

@odeke-em
Copy link
Member

/cc @griesemer @mdempsky for awareness during Go1.10.

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

5 participants