mirror of
https://github.com/golang/go
synced 2024-11-24 08:20:03 -07:00
go/parser: permit parentheses in receiver types
Pending acceptance of CL 101500044 and adjustment of test/fixedbugs/bug299.go. LGTM=adonovan R=golang-codereviews, adonovan CC=golang-codereviews https://golang.org/cl/110160043
This commit is contained in:
parent
89f185fe8a
commit
ef639b0936
@ -2310,9 +2310,9 @@ func (p *parser) parseReceiver(scope *ast.Scope) *ast.FieldList {
|
||||
return par
|
||||
}
|
||||
|
||||
// recv type must be of the form ["*"] identifier
|
||||
// recv type must be of the form ["*"] identifier, possibly using parentheses
|
||||
recv := par.List[0]
|
||||
base := deref(recv.Type)
|
||||
base := unparen(deref(unparen(recv.Type)))
|
||||
if _, isIdent := base.(*ast.Ident); !isIdent {
|
||||
if _, isBad := base.(*ast.BadExpr); !isBad {
|
||||
// only report error if it's a new one
|
||||
|
@ -35,6 +35,9 @@ var valids = []string{
|
||||
`package p; func f() { for _ = range "foo" + "bar" {} };`,
|
||||
`package p; func f() { var s []int; g(s[:], s[i:], s[:j], s[i:j], s[i:j:k], s[:j:k]) };`,
|
||||
`package p; var ( _ = (struct {*T}).m; _ = (interface {T}).m )`,
|
||||
`package p; func ((T),) m() {}`,
|
||||
`package p; func ((*T),) m() {}`,
|
||||
`package p; func (*(T),) m() {}`,
|
||||
}
|
||||
|
||||
func TestValid(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user