{"issue":{"created_at":"2011-11-20T02:37:38Z","state":"open","updated_at":"2011-11-28T11:43:41Z","user":{"gravatar_id":"8e830af2c64e2a4bbda590f2d7b95053","id":10632,"url":"https://api.github.com/users/goatslacker","avatar_url":"https://secure.gravatar.com/avatar/8e830af2c64e2a4bbda590f2d7b95053?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"goatslacker"},"comments":2,"body":"Isn't this supposed to complain?\r\n\r\n    /*jshint shadow: true */\r\n    function foo() {\r\n      var bar = true;\r\n      function baz() {\r\n        var foo = true;\r\n        var bar = true;\r\n      }\r\n    }\r\n\r\nYet this complains\r\n\r\n    function foo() {\r\n       var foo = true;\r\n    }\r\n\r\nAnd so does this:\r\n\r\n    function foo() {\r\n       var bar = 1;\r\n       var bar = 2;\r\n    }","assignee":null,"id":2290902,"number":350,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[{"name":"bug","color":"e10c02","url":"https://api.github.com/repos/jshint/jshint/labels/bug"}],"title":"shadow doesn't work sometimes","closed_at":null,"html_url":"https://github.com/jshint/jshint/issues/350","url":"https://api.github.com/repos/jshint/jshint/issues/350","milestone":null},"action":"created","comment":{"created_at":"2011-11-28T11:43:41Z","updated_at":"2011-11-28T11:43:41Z","user":{"gravatar_id":"0bbd585a794f22f3cf8eed34111d90dd","id":639482,"url":"https://api.github.com/users/WolfgangKluge","avatar_url":"https://secure.gravatar.com/avatar/0bbd585a794f22f3cf8eed34111d90dd?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"WolfgangKluge"},"body":"Hmmm, don't know. These are simple cases of closures.\r\n\r\n`shadow` should recognize cases where you \"redefine\" a variable.\r\n\r\n```javascript\r\nvar x = 2;\r\nvar x = 3;\r\n```\r\n\r\nThe difference to a a closure is, that a closure does not affect the \"overwritten\" variable (after the code is executed). So (if a warning/error should be thrown) we need a new option for such warnings.\r\n\r\n```javascript\r\nvar x = 2;\r\nfunction y() {\r\n    var x = 3;\r\n}\r\n```\r\n\r\n\r\nBut there is another error (in the online version, not tested in HEAD yet).\r\n\r\n```javascript\r\n/*jshint shadow: false*/\r\nvar x = 2;\r\nvar x = 3;\r\n```\r\nand\r\n\r\n```javascript\r\n/*jshint shadow: false*/\r\nfunction y() {\r\n    var x = 2;\r\n    var x = 3;\r\n}\r\n```\r\n\r\nbehave different.","id":2895843,"url":"https://api.github.com/repos/jshint/jshint/issues/comments/2895843"}}