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: false positive error #24944

dotaheor opened this issue Apr 19, 2018 · 1 comment


None yet
2 participants
Copy link

commented Apr 19, 2018

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

go version go1.10.1 linux/amd64

Does this issue reproduce with the latest release?


What did you do?

package main

func main() {
	// The following line compiles error: 
	//     syntax error: unexpected return at end of statement
	statRuneCount := func (s string) (n int) {for range s {n++} return}

What did you expect to see?

No errors.

What did you see instead?

./a.go:6:62: syntax error: unexpected return at end of statemen

This comment has been minimized.

Copy link

commented Apr 19, 2018

sorry, looks when a semicolon is inserted before return, it will compile okay.

statRuneCount := func (s string) (n int) {for range s {n++}; return}

@dotaheor dotaheor closed this Apr 19, 2018

@golang golang locked and limited conversation to collaborators Apr 19, 2019

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.