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

Spec elides ';' illegally after simple statement when switch expression elided #697

Closed
stevenblenkinsop opened this issue Mar 28, 2010 · 1 comment

Comments

@stevenblenkinsop
Copy link

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
1. Read the spec
2. Try the code, just to be sure: both gofmt and 8g reject it

What is the expected output? What do you see instead?
In spec, expected:
switch x := f(); {  // missing switch expression means "true"
case x < 0: return -x
default: return x
}

Found:
switch x := f() {  // missing switch expression means "true"
case x < 0: return -x
default: return x
}

http://golang.org/doc/go_spec.html#Switch_statements

What is your $GOOS?  $GOARCH?
linux 386

Which revision are you using?  (hg identify)
cf3701cfac15 tip

Please provide any additional information below.
Unless the implementation is wrong, and you are supposed to be able to 
elide the ';' after the simple statement (though this seems unlikely). 
Either way, there's a discord.
@adg
Copy link
Contributor

adg commented Mar 29, 2010

Comment 1:

The spec describes the switch statement as:
ExprSwitchStmt = "switch" [ SimpleStmt ";" ] [ Expression ] "{" { ExprCaseClause } "}" .
so the example without the semicolon is wrong.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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

3 participants