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

Comments

Projects
None yet
5 participants
@ALTree
Copy link
Member

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 label Jun 27, 2017

@kshvmdn

This comment has been minimized.

Copy link
Contributor

commented Jun 27, 2017

Can I have a go at this?

@bradfitz

This comment has been minimized.

Copy link
Member

commented Jun 27, 2017

@kshvmdn, always. No need to ask.

@kshvmdn

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link

commented Jun 27, 2017

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

@odeke-em

This comment has been minimized.

Copy link
Member

commented Jul 21, 2017

/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.
You can’t perform that action at this time.