mirror of https://github.com/golang/go.git
go/parser: match go/defer error message of syntax package
Adjust corresponding type checker tests accordingly. For #54511. Change-Id: Ieaf29f26c0877973fc0acbde35292cd69a4b709c Reviewed-on: https://go-review.googlesource.com/c/go/+/425007 Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
95a786da12
commit
b9bf824655
|
|
@ -1997,7 +1997,7 @@ func (p *parser) parseCallExpr(callType string) *ast.CallExpr {
|
|||
}
|
||||
if _, isBad := x.(*ast.BadExpr); !isBad {
|
||||
// only report error if it's a new one
|
||||
p.error(p.safePos(x.End()), fmt.Sprintf("function must be invoked in %s statement", callType))
|
||||
p.error(p.safePos(x.End()), fmt.Sprintf("expression in %s must be function call", callType))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,8 +170,8 @@ var invalids = []string{
|
|||
`package p; func f() { for x /* ERROR "boolean or range expression" */ := []string {} }`,
|
||||
`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 "function must be invoked" */ }`,
|
||||
`package p; func f() { defer func() {} /* ERROR HERE "function must be invoked" */ }`,
|
||||
`package p; func f() { go f /* ERROR HERE "must be function call" */ }`,
|
||||
`package p; func f() { defer func() {} /* ERROR HERE "must be function call" */ }`,
|
||||
`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) _()`,
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ func selects() {
|
|||
}
|
||||
|
||||
func gos() {
|
||||
go 1 /* ERROR HERE "function must be invoked" */
|
||||
go 1 /* ERROR HERE "must be function call" */
|
||||
go int /* ERROR "go requires function call, not conversion" */ (0)
|
||||
go gos()
|
||||
var c chan int
|
||||
|
|
@ -238,7 +238,7 @@ func gos() {
|
|||
}
|
||||
|
||||
func defers() {
|
||||
defer 1 /* ERROR HERE "function must be invoked" */
|
||||
defer 1 /* ERROR HERE "must be function call" */
|
||||
defer int /* ERROR "defer requires function call, not conversion" */ (0)
|
||||
defer defers()
|
||||
var c chan int
|
||||
|
|
|
|||
Loading…
Reference in New Issue