-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
Milestone
Description
by dmitrymaluka:
package main var i int //var i *int func (p *i) f() { } func main() { } ./indir.go:6: invalid indirect of i (type int) I expect the error message to be "is not a type". After replacing i declaration by the commented one, where i is a pointer variable (var i *int), the error message is correct: ./indir.go:6: *i is not a type Quoting myself (https://groups.google.com/forum/#!msg/golang-nuts/oRTdZYmkpqg/xKtazXH44N0J): "Ok, as far as I understand now, the compiler was dealing with the AST node *i treating it as a pointer indirection. But why it did that in the first place? According to http://golang.org/ref/spec#Method_declarations there is no place for a pointer indirection, syntactically. This behavior looks strange to me, and the resulting error message is a bit confusing."