CallStmt struct {
Tok token // Go or Defer
- Call *CallExpr
+ Call Expr
stmt
}
x = t
}
- cx, ok := x.(*CallExpr)
- if !ok {
- p.errorAt(x.Pos(), fmt.Sprintf("expression in %s must be function call", s.Tok))
- // already progressed, no need to advance
- cx = new(CallExpr)
- cx.pos = x.Pos()
- cx.Fun = x // assume common error of missing parentheses (function invocation)
+ // TODO(gri) Now that we don't store a CallExpr in a CallStmt anymore
+ // we might as well leave this check to the type checker.
+ // Adjust this here and in go/parser eventually.
+ if _, ok := x.(*CallExpr); !ok {
+ // only report an error if it's a new one
+ if bad, ok := x.(*BadExpr); !ok {
+ p.errorAt(x.Pos(), fmt.Sprintf("expression in %s must be function call", s.Tok))
+ // already progressed, no need to advance
+ bad = new(BadExpr)
+ bad.pos = x.Pos()
+ x = bad
+ }
}
- s.Call = cx
+ s.Call = x
return s
}
// Line 9 must end in EOF for this test (no newline).
package e
-func([<-chan<-[func /* ERROR unexpected u */ u){go /* ERROR must be function call */
\ No newline at end of file
+func([<-chan<-[func /* ERROR unexpected u */ u){go
\ No newline at end of file
check.scope = check.scope.Parent()
}
-func (check *Checker) suspendedCall(keyword string, call *syntax.CallExpr) {
+func (check *Checker) suspendedCall(keyword string, call syntax.Expr) {
var x operand
var msg string
switch check.rawExpr(&x, call, nil, false) {
}
func gos() {
- go 1 /* ERROR must be function call */ /* ERROR cannot call non-function */
+ go 1 /* ERROR must be function call */
go int /* ERROR "go requires function call, not conversion" */ (0)
go gos()
var c chan int
}
func defers() {
- defer 1 /* ERROR must be function call */ /* ERROR cannot call non-function */
+ defer 1 /* ERROR must be function call */
defer int /* ERROR "defer requires function call, not conversion" */ (0)
defer defers()
var c chan int
// there yet, so put it here for now. See also #20800.)
package e
-func([<-chan<-[func u){go // ERROR "unexpected u", ERROR "must be function call"
\ No newline at end of file
+func([<-chan<-[func u){go // ERROR "unexpected u"
\ No newline at end of file
package p
+// TODO(gri) The "not used" errors should not be reported.
+
import (
- "fmt"
- "math"
+ "fmt" // ERROR "imported and not used"
+ "math" // ERROR "imported and not used"
)
func f() {
- var i int
+ var i int // ERROR "i declared but not used"
defer func() { fmt.Println() } // ERROR "must be function call"
go func() { _ = math.Sin(0) } // ERROR "must be function call"
go func() { _ = i} // ERROR "must be function call"