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

all: string(2) doesn't throw an error #18578

Closed
ghost opened this issue Jan 9, 2017 · 1 comment
Closed

all: string(2) doesn't throw an error #18578

ghost opened this issue Jan 9, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Jan 9, 2017

Go 1.7.3

What did you do?

string(1)
https://play.golang.org/p/rut8mpiipO

What did you expect to see?

"cannot convert 1 to type string" - compile error

What did you see instead?

Integer has been converted in a string empty value.

@ALTree
Copy link
Member

ALTree commented Jan 9, 2017

Spec (https://golang.org/ref/spec#Conversions):

Conversions to and from a string type
Converting a signed or unsigned integer value to a string type yields a string containing the UTF-8 representation of the integer

The fact that this is bad is #3939, labelled go2 since it can't be changed now (because of the Go 1 compatibility promise).

@ALTree ALTree closed this as completed Jan 9, 2017
@golang golang locked and limited conversation to collaborators Jan 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants