{"action":"created","issue":{"url":"https://api.github.com/repos/za-creature/coffeescope/issues/12","repository_url":"https://api.github.com/repos/za-creature/coffeescope","labels_url":"https://api.github.com/repos/za-creature/coffeescope/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/za-creature/coffeescope/issues/12/comments","events_url":"https://api.github.com/repos/za-creature/coffeescope/issues/12/events","html_url":"https://github.com/za-creature/coffeescope/issues/12","id":152774327,"number":12,"title":"Switch in class method crashes","user":{"login":"srgraham","id":1577527,"avatar_url":"https://avatars.githubusercontent.com/u/1577527?v=3","gravatar_id":"","url":"https://api.github.com/users/srgraham","html_url":"https://github.com/srgraham","followers_url":"https://api.github.com/users/srgraham/followers","following_url":"https://api.github.com/users/srgraham/following{/other_user}","gists_url":"https://api.github.com/users/srgraham/gists{/gist_id}","starred_url":"https://api.github.com/users/srgraham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srgraham/subscriptions","organizations_url":"https://api.github.com/users/srgraham/orgs","repos_url":"https://api.github.com/users/srgraham/repos","events_url":"https://api.github.com/users/srgraham/events{/privacy}","received_events_url":"https://api.github.com/users/srgraham/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-03T13:33:12Z","updated_at":"2016-05-03T13:40:20Z","closed_at":null,"body":"I'm running version 0.2.3 of coffeescope against some of my work projects. I'm getting this error, which I think happens because of a switch inside a class method. Here's some example code that causes a crash:\r\n\r\n```coffee\r\nclass Abc\r\n  someFunc: (str)->\r\n    switch str\r\n      when 'something'\r\n        a = 8\r\n\r\n```\r\n\r\n\r\nAnd here's the error I get\r\n```\r\nscottgra$ coffeelint -f ~/htdocs/coffeelint.json broke.coffee \r\n/usr/local/lib/node_modules/coffeescope2/lib/Scope.js:121\r\n            return a.first_line < b.first_line || (a.first_line === b.first_line && a.first_column <= b.first_column);\r\n                    ^\r\n\r\nTypeError: Cannot read property 'first_line' of undefined\r\n  at isBefore (/usr/local/lib/node_modules/coffeescope2/lib/Scope.js:121:21)\r\n  at checkUsedBeforeDefined (/usr/local/lib/node_modules/coffeescope2/lib/Scope.js:126:18)\r\n  at Scope.module.exports.Scope.appendErrors (/usr/local/lib/node_modules/coffeescope2/lib/Scope.js:140:11)\r\n  at Scope.appendErrors (/usr/local/lib/node_modules/coffeescope2/lib/Scope.js:5:59)\r\n  at ScopeLinter.module.exports.ScopeLinter.newScope (/usr/local/lib/node_modules/coffeescope2/lib/ScopeLinter.js:86:20)\r\n  at ScopeLinter.newScope (/usr/local/lib/node_modules/coffeescope2/lib/ScopeLinter.js:5:59)\r\n  at ScopeLinter.module.exports.ScopeLinter.lint (/usr/local/lib/node_modules/coffeescope2/lib/ScopeLinter.js:46:14)\r\n  at ScopeLinter.lint (/usr/local/lib/node_modules/coffeescope2/lib/ScopeLinter.js:5:59)\r\n  at Coffeescope2.module.exports.Coffeescope2.lintAST (/usr/local/lib/node_modules/coffeescope2/lib/index.js:31:38)\r\n  at ASTLinter.module.exports.ASTLinter.lint (/Library/WebServer/htdocs/github/coffeescope/node_modules/coffeelint/lib/coffeelint.js:613:43)\r\n  at Object.coffeelint.lint (/Library/WebServer/htdocs/github/coffeescope/node_modules/coffeelint/lib/coffeelint.js:370:67)\r\n  at ErrorReport.module.exports.ErrorReport.lint (/Library/WebServer/htdocs/github/coffeescope/node_modules/coffeelint/lib/coffeelint.js:758:51)\r\n  at lintFiles (/Library/WebServer/htdocs/github/coffeescope/node_modules/coffeelint/lib/commandline.js:98:19)\r\n  at Object.<anonymous> (/Library/WebServer/htdocs/github/coffeescope/node_modules/coffeelint/lib/commandline.js:251:21)\r\n  at Object.<anonymous> (/Library/WebServer/htdocs/github/coffeescope/node_modules/coffeelint/lib/commandline.js:256:4)\r\n  at Module._compile (module.js:413:34)\r\n  at Object.Module._extensions..js (module.js:422:10)\r\n  at Module.load (module.js:357:32)\r\n  at Function.Module._load (module.js:314:12)\r\n  at Module.require (module.js:367:17)\r\n  at require (internal/module.js:16:19)\r\n  at Object.<anonymous> (/usr/local/lib/node_modules/coffeelint/bin/coffeelint:34:5)\r\n  at Module._compile (module.js:413:34)\r\n  at Object.Module._extensions..js (module.js:422:10)\r\n  at Module.load (module.js:357:32)\r\n  at Function.Module._load (module.js:314:12)\r\n  at Function.Module.runMain (module.js:447:10)\r\n  at startup (node.js:142:18)\r\n  at node.js:939:3\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/za-creature/coffeescope/issues/comments/216530457","html_url":"https://github.com/za-creature/coffeescope/issues/12#issuecomment-216530457","issue_url":"https://api.github.com/repos/za-creature/coffeescope/issues/12","id":216530457,"user":{"login":"za-creature","id":1210845,"avatar_url":"https://avatars.githubusercontent.com/u/1210845?v=3","gravatar_id":"","url":"https://api.github.com/users/za-creature","html_url":"https://github.com/za-creature","followers_url":"https://api.github.com/users/za-creature/followers","following_url":"https://api.github.com/users/za-creature/following{/other_user}","gists_url":"https://api.github.com/users/za-creature/gists{/gist_id}","starred_url":"https://api.github.com/users/za-creature/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/za-creature/subscriptions","organizations_url":"https://api.github.com/users/za-creature/orgs","repos_url":"https://api.github.com/users/za-creature/repos","events_url":"https://api.github.com/users/za-creature/events{/privacy}","received_events_url":"https://api.github.com/users/za-creature/received_events","type":"User","site_admin":false},"created_at":"2016-05-03T13:40:20Z","updated_at":"2016-05-03T13:40:20Z","body":"Having trouble reproducing this; what's your config like?\r\n\r\n```bash\r\nB:\\coffeescope2>coffeelint foo.coffee\r\n  ⚡ foo.coffee\r\n     ⚡ #1: Variable \"Abc\" is never used.\r\n     ⚡ #5: Variable \"a\" is never used.\r\n\r\n⚡ Warning! » 0 errors and 2 warnings in 1 file\r\n```\r\n\r\nfoo.coffee\r\n```coffeescript\r\nclass Abc\r\n    someFunc: (str) ->\r\n        switch str\r\n            when \"something\"\r\n                a = 8\r\n```\r\n\r\ncoffeelint.json\r\n```\r\n\"check_scope\": {\r\n    \"module\": \"coffeescope2\",\r\n    \"level\": \"warn\",\r\n    \"environments\": [],\r\n    \"globals\": {},\r\n    \"overwrite\": true,\r\n    \"same_scope\": false,\r\n    \"shadow\": true,\r\n    \"shadow_exceptions\": [\"err\", \"next\"],\r\n    \"undefined\": true,\r\n    \"unused_variables\": true,\r\n    \"unused_arguments\": false\r\n}\r\n```"}}