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

Closed
dotaheor opened this issue Apr 19, 2018 · 1 comment
Closed

cmd/compile: false positive error #24944

dotaheor opened this issue Apr 19, 2018 · 1 comment

Comments

@dotaheor
Copy link

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

go version go1.10.1 linux/amd64

Does this issue reproduce with the latest release?

yes

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}
	println(statRuneCount("abc"))
}

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
@dotaheor
Copy link
Author

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

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

@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.
Projects
None yet
Development

No branches or pull requests

2 participants