You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
http://play.golang.org/p/ZNCKVEGTmv
package main
import "bufio"
func (x ***int) m() {}
func (x chan int) m() {}
func (x *bufio.Reader) m() {}
The compiler can print good errors for this (click compile):
prog.go:5: invalid receiver type ***int (**int is an unnamed type)
prog.go:6: invalid receiver type chan int (chan int is an unnamed type)
prog.go:7: cannot define new methods on non-local type bufio.Reader
go/parser rejects it early (click format):
/tmp/x.go:5:10: expected (unqualified) identifier
/tmp/x.go:6:9: expected (unqualified) identifier
/tmp/x.go:7:10: expected (unqualified) identifier
Since ast.FuncDecl.Recv is just a *FieldList, it seems like the parser can easily accept
and represent the input without changes to go/ast or go/printer, and then go/types (or a
compiler using go/parser) can do the semantic rejection of the receiver types at a
higher level and give better errors.
The text was updated successfully, but these errors were encountered:
The ast and printer don't care, and go/types can provide
a better error message.
This change requires an update to the tests for go/types
(go.tools repo). CL forthcoming.
Fixesgolang#8493.
LGTM=adonovan
R=rsc, adonovan
CC=golang-codereviews
https://golang.org/cl/123010044
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jul 9, 2018
The ast and printer don't care, and go/types can provide
a better error message.
This change requires an update to the tests for go/types
(go.tools repo). CL forthcoming.
Fixesgolang#8493.
LGTM=adonovan
R=rsc, adonovan
CC=golang-codereviews
https://golang.org/cl/123010044
This issue was closed.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: