Skip to content

cmd/compile, go/types: erroneously accepts method expressions with anonymous receiver type #15721

@mdempsky

Description

@mdempsky

The Go spec's grammar restricts method expressions to using either a named type or pointer to a named type:

MethodExpr    = ReceiverType "." MethodName .
ReceiverType  = TypeName | "(" "*" TypeName ")" | "(" ReceiverType ")" .

cmd/compile erroneously accepts this Go source:

package p
var _ = struct{ error }.Error

go/types erroneously accepts it too.

gccgo correctly rejects with the error message "method expression requires named type or pointer to named type"

/cc @griesemer @ianlancetaylor

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions