{"action":"opened","issue":{"url":"https://api.github.com/repos/golang/go/issues/11944","labels_url":"https://api.github.com/repos/golang/go/issues/11944/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/11944/comments","events_url":"https://api.github.com/repos/golang/go/issues/11944/events","html_url":"https://github.com/golang/go/issues/11944","id":98214077,"number":11944,"title":"go/types: does not give types to selectors","user":{"login":"dvyukov","id":1095328,"avatar_url":"https://avatars.githubusercontent.com/u/1095328?v=3","gravatar_id":"","url":"https://api.github.com/users/dvyukov","html_url":"https://github.com/dvyukov","followers_url":"https://api.github.com/users/dvyukov/followers","following_url":"https://api.github.com/users/dvyukov/following{/other_user}","gists_url":"https://api.github.com/users/dvyukov/gists{/gist_id}","starred_url":"https://api.github.com/users/dvyukov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvyukov/subscriptions","organizations_url":"https://api.github.com/users/dvyukov/orgs","repos_url":"https://api.github.com/users/dvyukov/repos","events_url":"https://api.github.com/users/dvyukov/events{/privacy}","received_events_url":"https://api.github.com/users/dvyukov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"griesemer","id":8528975,"avatar_url":"https://avatars.githubusercontent.com/u/8528975?v=3","gravatar_id":"","url":"https://api.github.com/users/griesemer","html_url":"https://github.com/griesemer","followers_url":"https://api.github.com/users/griesemer/followers","following_url":"https://api.github.com/users/griesemer/following{/other_user}","gists_url":"https://api.github.com/users/griesemer/gists{/gist_id}","starred_url":"https://api.github.com/users/griesemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/griesemer/subscriptions","organizations_url":"https://api.github.com/users/griesemer/orgs","repos_url":"https://api.github.com/users/griesemer/repos","events_url":"https://api.github.com/users/griesemer/events{/privacy}","received_events_url":"https://api.github.com/users/griesemer/received_events","type":"User","site_admin":false},"milestone":null,"comments":0,"created_at":"2015-07-30T16:45:35Z","updated_at":"2015-07-30T16:45:35Z","closed_at":null,"body":"The following program:\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"go/ast\"\r\n\t\"go/parser\"\r\n\t\"go/token\"\r\n\t\"go/types\"\r\n)\r\n\r\nfunc main() {\r\n\tfset := token.NewFileSet()\r\n\tf, err := parser.ParseFile(fset, \"test.go\", src, 0)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\tinfo := &types.Info{Types: make(map[ast.Expr]types.TypeAndValue)}\r\n\tcfg := &types.Config{}\r\n\t_, err = cfg.Check(\"test\", fset, []*ast.File{f}, info)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\tfor n, t := range info.Types {\r\n\t\tfmt.Printf(\"%+v: %v\\n\", n, t)\r\n\t}\r\n}\r\n\r\nconst src = `\r\npackage x\r\n\r\ntype X struct {\r\n\tf int\r\n}\r\n\r\nfunc foo(x *X) int {\r\n\treturn x.f\r\n}\r\n```\r\noutputs:\r\n```\r\nint: {3 int <nil>}\r\nx: {5 *test.X <nil>}\r\n&{X:x Sel:f}: {5 int <nil>}\r\nint: {3 int <nil>}\r\n&{Struct:20 Fields:0xc820014660 Incomplete:false}: {3 struct{f int} <nil>}\r\nX: {3 test.X <nil>}\r\n&{Star:50 X:X}: {3 *test.X <nil>}\r\n```\r\n\r\nYou can see that selector ```f``` in expression ```x.f``` did not get type.\r\nIt should have a type, when you recursively walk an expression that expect that all subexpressions are typed or constants. But these are completely unindentified.\r\n\r\nThe spec says that selectors have types; and in fact type of the selector expression itself is determined by type of the selector:\r\n```\r\nFor a primary expression x that is not a package name, the selector expression\r\nx.f\r\ndenotes the field or method f of the value x (or sometimes *x; see below). The identifier f is called the (field or method) selector; it must not be the blank identifier. The type of the selector expression is the type of f. If x is a package name, see the section on qualified identifiers.\r\n```\r\n\r\ngo version devel +b7205b9 Thu Jul 30 05:57:37 2015 +0000 linux/amd64"}}