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: send statements cannot be parenthesized #6791

Closed
griesemer opened this issue Nov 19, 2013 · 6 comments
Closed

cmd/compile: send statements cannot be parenthesized #6791

griesemer opened this issue Nov 19, 2013 · 6 comments

Comments

@griesemer
Copy link
Contributor

The following program

http://play.golang.org/p/JAKJ9WVL00

is accepted w/o compilation error. However, a send statement is a regular statement and
cannot be parenthesized. This is probably an artifact from the time when sends were
expressions.

gccgo reports an error:

$ cat x.go
package main

func main() {
     var ch chan int
     (ch<-0)
}

$ gccgo x.go
x.go:5:9: error: missing ')'
      (ch<-0)
         ^
x.go:5:12: error: expected ';' or '}' or newline
      (ch<-0)
            ^

And so does gotype:

$ gotype x.go
x.go:5:5: expected ')', found '<-'
x.go:6:2: expected '}', found 'EOF'
@griesemer
Copy link
Contributor Author

Comment 1:

Tests should incorporate sends in select statements (
http://play.golang.org/p/0I4FtkOAEe ).

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 2:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 3:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 4:

Labels changed: added repo-main.

@rsc rsc removed the compiler-bug label Apr 10, 2015
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title cmd/gc: send statements cannot be parenthesized cmd/compile: send statements cannot be parenthesized Jun 8, 2015
@odeke-em
Copy link
Member

@griesemer this is no longer the case in Go1.8, we now correctly report that those cases have unexpected tokens and fail to compile.

screen shot 2017-02-22 at 5 41 36 pm

screen shot 2017-02-22 at 5 42 32 pm

@griesemer
Copy link
Contributor Author

Thanks, @odeke-em for digging this one out. Yes, fixed because the 1.8 parser doesn't parse send statements as expressions.

@golang golang locked and limited conversation to collaborators Feb 23, 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

4 participants