{"action":"opened","issue":{"url":"https://api.github.com/repos/babel/babel/issues/1680","labels_url":"https://api.github.com/repos/babel/babel/issues/1680/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/1680/comments","events_url":"https://api.github.com/repos/babel/babel/issues/1680/events","html_url":"https://github.com/babel/babel/issues/1680","id":85190603,"number":1680,"title":"Const is accidentally hoisted","user":{"login":"tel","id":1141,"avatar_url":"https://avatars.githubusercontent.com/u/1141?v=3","gravatar_id":"","url":"https://api.github.com/users/tel","html_url":"https://github.com/tel","followers_url":"https://api.github.com/users/tel/followers","following_url":"https://api.github.com/users/tel/following{/other_user}","gists_url":"https://api.github.com/users/tel/gists{/gist_id}","starred_url":"https://api.github.com/users/tel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tel/subscriptions","organizations_url":"https://api.github.com/users/tel/orgs","repos_url":"https://api.github.com/users/tel/repos","events_url":"https://api.github.com/users/tel/events{/privacy}","received_events_url":"https://api.github.com/users/tel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-04T17:11:52Z","updated_at":"2015-06-04T17:11:52Z","closed_at":null,"body":"The following code should be an error in ES6 (to my understanding)\r\n\r\n```javascript\r\nfunction foo() {\r\n  return x;\r\n}\r\n\r\nconst x = 3;\r\nconsole.log(foo());\r\n```\r\n\r\nThe reason it should fail is because `const`s are unhoisted. However, babel compiles this to\r\n\r\n```javascript\r\n\"use strict\";\r\n\r\nfunction foo() {\r\n  return x;\r\n}\r\n\r\nvar x = 3;\r\nconsole.log(foo());\r\n```\r\n\r\nand since the `const` is realized as a `var` it gets accidentally hoisted and the code prints `3`."}}