{"action":"opened","issue":{"url":"https://api.github.com/repos/go-lang-plugin-org/go-lang-idea-plugin/issues/1269","labels_url":"https://api.github.com/repos/go-lang-plugin-org/go-lang-idea-plugin/issues/1269/labels{/name}","comments_url":"https://api.github.com/repos/go-lang-plugin-org/go-lang-idea-plugin/issues/1269/comments","events_url":"https://api.github.com/repos/go-lang-plugin-org/go-lang-idea-plugin/issues/1269/events","html_url":"https://github.com/go-lang-plugin-org/go-lang-idea-plugin/issues/1269","id":56914210,"number":1269,"title":"[1.0] Incorrect variable scope resolution in switch context","user":{"login":"dlsniper","id":607868,"avatar_url":"https://avatars.githubusercontent.com/u/607868?v=3","gravatar_id":"","url":"https://api.github.com/users/dlsniper","html_url":"https://github.com/dlsniper","followers_url":"https://api.github.com/users/dlsniper/followers","following_url":"https://api.github.com/users/dlsniper/following{/other_user}","gists_url":"https://api.github.com/users/dlsniper/gists{/gist_id}","starred_url":"https://api.github.com/users/dlsniper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlsniper/subscriptions","organizations_url":"https://api.github.com/users/dlsniper/orgs","repos_url":"https://api.github.com/users/dlsniper/repos","events_url":"https://api.github.com/users/dlsniper/events{/privacy}","received_events_url":"https://api.github.com/users/dlsniper/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"ignatov","id":426890,"avatar_url":"https://avatars.githubusercontent.com/u/426890?v=3","gravatar_id":"","url":"https://api.github.com/users/ignatov","html_url":"https://github.com/ignatov","followers_url":"https://api.github.com/users/ignatov/followers","following_url":"https://api.github.com/users/ignatov/following{/other_user}","gists_url":"https://api.github.com/users/ignatov/gists{/gist_id}","starred_url":"https://api.github.com/users/ignatov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ignatov/subscriptions","organizations_url":"https://api.github.com/users/ignatov/orgs","repos_url":"https://api.github.com/users/ignatov/repos","events_url":"https://api.github.com/users/ignatov/events{/privacy}","received_events_url":"https://api.github.com/users/ignatov/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/go-lang-plugin-org/go-lang-idea-plugin/milestones/6","labels_url":"https://api.github.com/repos/go-lang-plugin-org/go-lang-idea-plugin/milestones/6/labels","id":169045,"number":6,"title":"1.0.0","description":"","creator":{"login":"mtoader","id":372850,"avatar_url":"https://avatars.githubusercontent.com/u/372850?v=3","gravatar_id":"","url":"https://api.github.com/users/mtoader","html_url":"https://github.com/mtoader","followers_url":"https://api.github.com/users/mtoader/followers","following_url":"https://api.github.com/users/mtoader/following{/other_user}","gists_url":"https://api.github.com/users/mtoader/gists{/gist_id}","starred_url":"https://api.github.com/users/mtoader/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtoader/subscriptions","organizations_url":"https://api.github.com/users/mtoader/orgs","repos_url":"https://api.github.com/users/mtoader/repos","events_url":"https://api.github.com/users/mtoader/events{/privacy}","received_events_url":"https://api.github.com/users/mtoader/received_events","type":"User","site_admin":false},"open_issues":45,"closed_issues":55,"state":"open","created_at":"2012-09-02T21:49:33Z","updated_at":"2015-02-07T15:13:22Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2015-02-07T15:13:22Z","updated_at":"2015-02-07T15:13:22Z","closed_at":null,"body":"In the following example, the var ```err``` declared in ```main()``` will be flagged as unused variable.\r\nHowever, in the ```switch``` syntax it it used correctly.\r\nIf you look at the screenshots, it reveals how the shorthand assignment from withing the case statement \r\nwill take over as the one that declares the variable for the remaining of the code execution while in the switch statement.\r\n\r\n```go\r\npackage main\r\n\r\nimport \"fmt\"\r\n\r\nfunc Demo() error {\r\n\treturn fmt.Errorf(\"err\")\r\n}\r\n\r\nfunc main() {\r\n\tvar err error\r\n\r\n\tswitch  {\r\n\tcase 1==2:\r\n\t\terr := Demo()\r\n\t\tpanic(err)\r\n\tdefault:\r\n\t\terr = Demo()\r\n\t\tpanic(err)\r\n\t}\r\n}\r\n```\r\n\r\n![snapshot109](https://cloud.githubusercontent.com/assets/607868/6092552/26096fb0-aee4-11e4-978f-95fc5aaafcc5.png)\r\n\r\n![snapshot110](https://cloud.githubusercontent.com/assets/607868/6092554/34cdcb68-aee4-11e4-93a6-14b19faf73d3.png)\r\n\r\nThank you."}}