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

runtime: bug with indexes while range in string #26542

Closed
jflenero opened this issue Jul 23, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@jflenero
Copy link

commented Jul 23, 2018

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

go version go1.10.3 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

https://play.golang.org/p/SGSiTfrzD3P

What did you expect to see?

We should expect a range of 37, as there are 37 characters in the string.

What did you see instead?

A range of 38, the special characters, in this case 'Ñ' make the indexes step further

@cuonglm

This comment has been minimized.

Copy link
Contributor

commented Jul 23, 2018

I think it's intended, see https://blog.golang.org/strings

@myitcv

This comment has been minimized.

Copy link
Member

commented Jul 23, 2018

This is not a bug:

https://golang.org/ref/spec#String_types
https://golang.org/ref/spec#For_statements (see the bit about range clauses, specifically for strings)

@myitcv myitcv closed this Jul 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.