{"action":"opened","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/7895","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/7895/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/7895/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/7895/events","html_url":"https://github.com/dotnet/roslyn/issues/7895","id":126071050,"number":7895,"title":"Local variable type is bound twice","user":{"login":"gafter","id":3804346,"avatar_url":"https://avatars.githubusercontent.com/u/3804346?v=3","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Compilers","name":"Area-Compilers","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Language-C%23","name":"Language-C#","color":"207de5"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Tenet-Performance","name":"Tenet-Performance","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-12T00:40:03Z","updated_at":"2016-01-12T00:40:03Z","closed_at":null,"body":"The type of a local variable is bound *twice* in the C# compiler. Here are the two places\r\n\r\nIn Binder_Statements.cs\r\n```cs\r\n        private BoundStatement BindDeclarationStatement(LocalDeclarationStatementSyntax node, DiagnosticBag diagnostics)\r\n        {\r\n            var typeSyntax = node.Declaration.Type;\r\n            bool isConst = node.IsConst;\r\n\r\n            bool isVar;\r\n            AliasSymbol alias;\r\n            TypeSymbol declType = BindVariableType(node, diagnostics, typeSyntax, ref isConst, isVar: out isVar, alias: out alias);\r\n```\r\n\r\nIn SourceLocalSymbol.cs (where diagnostics are computed and dropped on the floor):\r\n```cs\r\n        private TypeSymbol GetTypeSymbol()\r\n        {\r\n            var diagnostics = DiagnosticBag.GetInstance();\r\n\r\n            Binder typeBinder = this.binder;\r\n\r\n            bool isVar;\r\n            TypeSymbol declType = typeBinder.BindType(_typeSyntax, diagnostics, out isVar);\r\n```\r\n\r\nFor efficiency the compiler should bind each construct once."}}