{"action":"opened","issue":{"url":"https://api.github.com/repos/google/closure-compiler/issues/1687","repository_url":"https://api.github.com/repos/google/closure-compiler","labels_url":"https://api.github.com/repos/google/closure-compiler/issues/1687/labels{/name}","comments_url":"https://api.github.com/repos/google/closure-compiler/issues/1687/comments","events_url":"https://api.github.com/repos/google/closure-compiler/issues/1687/events","html_url":"https://github.com/google/closure-compiler/issues/1687","id":143320366,"number":1687,"title":"Falsy SHIFT_AMOUNT_OUT_OF_BOUNDS warning","user":{"login":"liolick","id":7496927,"avatar_url":"https://avatars.githubusercontent.com/u/7496927?v=3","gravatar_id":"","url":"https://api.github.com/users/liolick","html_url":"https://github.com/liolick","followers_url":"https://api.github.com/users/liolick/followers","following_url":"https://api.github.com/users/liolick/following{/other_user}","gists_url":"https://api.github.com/users/liolick/gists{/gist_id}","starred_url":"https://api.github.com/users/liolick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liolick/subscriptions","organizations_url":"https://api.github.com/users/liolick/orgs","repos_url":"https://api.github.com/users/liolick/repos","events_url":"https://api.github.com/users/liolick/events{/privacy}","received_events_url":"https://api.github.com/users/liolick/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-24T18:13:18Z","updated_at":"2016-03-24T18:13:18Z","closed_at":null,"body":"See https://groups.google.com/forum/#!msg/closure-compiler-discuss/uwHMX9Cgy1U/2zHbGAOpCgAJ\r\n\r\nThis code:\r\n/** @enum {number} */\r\nvar SomeEnum =\r\n{\r\n    val37: 37,\r\n    val38: 38,\r\n    val39: 39\r\n};\r\n\r\n/** @const {number} */\r\nvar kLowBitsCount = 31;\r\n\r\n/** @constructor */\r\nvar SomeClass = function()\r\n{\r\n    /** @type {number} */\r\n    this.categoriesHolderLow_ = 0;\r\n\r\n    /** @type {number} */\r\n    this.categoriesHolderHigh_ = 0;\r\n}\r\n\r\n/**\r\n * @param {!SomeEnum} category Number-based enum that has more than 32 values (34 actally)\r\n * @return {boolean}\r\n */\r\nSomeClass.prototype.checkCategory = function (category)\r\n{\r\n    if (category >= kLowBitsCount)   // kLowBitsCount is 31 so we never cross bounds\r\n    {\r\n        return !!(this.categoriesHolderHigh_ & (\r\n            1 << (category - kLowBitsCount)));  // <- warnings line\r\n    }\r\n    return !!(this.categoriesHolderLow_ & (1 << category));\r\n};\r\n\r\nvar c = new SomeClass();\r\nalert(c.checkCategory(SomeEnum.val38));\r\n\r\ndoes emit wrong warning at wrong place:\r\nJSC_SHIFT_AMOUNT_OUT_OF_BOUNDS: Shift amount out of bounds: NUMBER 38.0 5 [originalname: SomeEnum.val38] [source_file: Input_0] : number at line 5 character 11\r\n    val38: 38,\r\n           ^\r\n\r\nThough shift never get out of bounds here.\r\n\r\nhttps://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F**%2520%2540enum%2520%257Bnumber%257D%2520*%252F%250Avar%2520SomeEnum%2520%253D%250A%257B%250A%2520%2520%2520%2520val37%253A%252037%252C%250A%2520%2520%2520%2520val38%253A%252038%252C%250A%2520%2520%2520%2520val39%253A%252039%250A%257D%253B%250A%250A%252F**%2520%2540const%2520%257Bnumber%257D%2520*%252F%250Avar%2520kLowBitsCount%2520%253D%252031%253B%250A%250A%252F**%2520%2540constructor%2520*%252F%250Avar%2520SomeClass%2520%253D%2520function()%250A%257B%250A%2520%2520%2520%2520%252F**%2520%2540type%2520%257Bnumber%257D%2520*%252F%250A%2520%2520%2520%2520this.categoriesHolderLow_%2520%253D%25200%253B%250A%250A%2520%2520%2520%2520%252F**%2520%2540type%2520%257Bnumber%257D%2520*%252F%250A%2520%2520%2520%2520this.categoriesHolderHigh_%2520%253D%25200%253B%250A%257D%250A%250A%252F**%250A%2520*%2520%2540param%2520%257B!SomeEnum%257D%2520category%2520Number-based%2520enum%2520that%2520has%2520more%2520than%252032%2520values%2520(34%2520actally)%250A%2520*%2520%2540return%2520%257Bboolean%257D%250A%2520*%252F%250ASomeClass.prototype.checkCategory%2520%253D%2520function%2520(category)%250A%257B%250A%2520%2520%2520%2520if%2520(category%2520%253E%253D%2520kLowBitsCount)%2520%2520%2520%252F%252F%2520kLowBitsCount%2520is%252031%2520so%2520we%2520never%2520cross%2520bounds%250A%2520%2520%2520%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520return%2520!!(this.categoriesHolderHigh_%2520%2526%2520(%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%25201%2520%253C%253C%2520(category%2520-%2520kLowBitsCount)))%253B%2520%2520%252F%252F%2520%253C-%2520warnings%2520line%250A%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520return%2520!!(this.categoriesHolderLow_%2520%2526%2520(1%2520%253C%253C%2520category))%253B%250A%257D%253B%250A%250Avar%2520c%2520%253D%2520new%2520SomeClass()%253B%250Aalert(c.checkCategory(SomeEnum.val38))%253B%250A\r\n"}}