func (p *parser) parseCallExpr(callType string) *ast.CallExpr {
x := p.parseRhs() // could be a conversion: (some type)(x)
+ if t := unparen(x); t != x {
+ p.error(x.Pos(), fmt.Sprintf("expression in %s must not be parenthesized", callType))
+ x = t
+ }
if call, isCall := x.(*ast.CallExpr); isCall {
return call
}
`package p; func f() { for i /* ERROR "boolean or range expression" */ , x = []string {} }`,
`package p; func f() { for i /* ERROR "boolean or range expression" */ , x := []string {} }`,
`package p; func f() { go f /* ERROR HERE "must be function call" */ }`,
+ `package p; func f() { go ( /* ERROR "must not be parenthesized" */ f()) }`,
`package p; func f() { defer func() {} /* ERROR HERE "must be function call" */ }`,
+ `package p; func f() { defer ( /* ERROR "must not be parenthesized" */ f()) }`,
`package p; func f() { go func() { func() { f(x func /* ERROR "missing ','" */ (){}) } } }`,
`package p; func _() (type /* ERROR "found 'type'" */ T)(T)`,
`package p; func (type /* ERROR "found 'type'" */ T)(T) _()`,
func gos() {
go 1; /* ERROR "must be function call" */
go int /* ERROR "go requires function call, not conversion" */ (0)
+ go ( /* ERROR expression in go must not be parenthesized */ gos())
go gos()
var c chan int
go close(c)
func defers() {
defer 1; /* ERROR "must be function call" */
defer int /* ERROR "defer requires function call, not conversion" */ (0)
+ defer ( /* ERROR expression in defer must not be parenthesized */ defers())
defer defers()
var c chan int
defer close(c)