{"action":"closed","issue":{"url":"https://api.github.com/repos/babel/babel/issues/7823","repository_url":"https://api.github.com/repos/babel/babel","labels_url":"https://api.github.com/repos/babel/babel/issues/7823/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/7823/comments","events_url":"https://api.github.com/repos/babel/babel/issues/7823/events","html_url":"https://github.com/babel/babel/issues/7823","id":318224148,"number":7823,"title":"Babel transform hide ReferenceError with non-hoisted variables","user":{"login":"djfdev","id":6677248,"avatar_url":"https://avatars1.githubusercontent.com/u/6677248?v=4","gravatar_id":"","url":"https://api.github.com/users/djfdev","html_url":"https://github.com/djfdev","followers_url":"https://api.github.com/users/djfdev/followers","following_url":"https://api.github.com/users/djfdev/following{/other_user}","gists_url":"https://api.github.com/users/djfdev/gists{/gist_id}","starred_url":"https://api.github.com/users/djfdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djfdev/subscriptions","organizations_url":"https://api.github.com/users/djfdev/orgs","repos_url":"https://api.github.com/users/djfdev/repos","events_url":"https://api.github.com/users/djfdev/events{/privacy}","received_events_url":"https://api.github.com/users/djfdev/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-04-26T22:55:39Z","updated_at":"2018-05-04T16:10:53Z","closed_at":"2018-05-04T16:10:53Z","author_association":"NONE","body":"<!---\r\nThanks for filing an issue 😄 ! Before you submit, please read the following:\r\n\r\nSearch open/closed issues before submitting since someone might have asked the same thing before!\r\n\r\nIf you have a support request or question please submit them to one of this resources:\r\n\r\n* Slack Community: https://babeljs.slack.com (you can sign-up at https://slack.babeljs.io/ for an invite)\r\n* StackOverflow: https://stackoverflow.com/questions/tagged/babeljs using the tag `babeljs`\r\n* Also have a look at the readme for more information on how to get support:\r\n  https://github.com/babel/babel/blob/master/README.md\r\n\r\nIssues on GitHub are only related to problems of Babel itself and we cannot answer \r\nsupport questions here.\r\n-->\r\n\r\nBug report\r\n\r\n<!--- Provide a general summary of the issue in the title above -->\r\n\r\n### Input Code\r\n<!--- If you're describing a bug, please let us know which sample code reproduces your problem -->\r\n<!--- If you have link to our REPL or a standalone repo please link that! -->\r\n\r\nThe following will build without error in Babel:\r\n\r\n```js\r\nconst fn = () => {\r\n  if (x) return x\r\n  let x = true\r\n}\r\n\r\nfn() // ReferenceError: x is not defined\r\n```\r\n\r\nHowever, when ES6 transform is applied, the `let` declaration transpiles into a `var`, which is hoisted and run without error\r\n\r\n```js\r\nvar fn = function fn() {\r\n  if (x) return;\r\n  var x = true;\r\n};\r\n\r\nfn(); // OK\r\n```\r\n\r\n### Babel/Babylon Configuration (.babelrc, package.json, cli command)\r\n<!--- If describing a bug, tell us what your babel configuration looks like -->\r\n\r\n```js\r\n{\r\n  \"presets\": [\r\n    [\"babel-preset-env\", {\r\n      \"targets\": {\r\n        \"browsers\": [\"last 2 Chrome versions\"],\r\n        \"uglify\": true\r\n      }\r\n    }]\r\n  ]\r\n}\r\n```\r\n\r\n### Expected Behavior\r\n<!--- If you're describing a bug, tell us what should happen -->\r\n<!--- If you're suggesting a change/improvement, tell us how it should work -->\r\n\r\nI would expect Babel to warn me that my un-transpiled code would have caused an error, but the transpiled code prevents that error.\r\n\r\n### Current Behavior\r\n<!--- If describing a bug, tell us what happens instead of the expected behavior -->\r\n<!--- If suggesting a change/improvement, explain the difference from current behavior -->\r\n\r\nI can introduce a bug in my code without realizing it, because the transpiled version fixes said bug.\r\n\r\n### Possible Solution\r\n<!--- Not obligatory, but suggest a fix/reason for the bug, -->\r\n<!--- or ideas how to implement the addition or change -->\r\n\r\n### Context\r\n<!--- How has this issue affected you? What are you trying to accomplish? -->\r\n<!--- Providing context helps us come up with a solution that is most useful in the real world -->\r\n\r\nI actually removed the `uglify` option from my Babel configuration because I did not want to transpile everything into ES5 syntax. Suddenly, I was getting a `ReferenceError` in my code that previously worked fine.\r\n\r\n### Your Environment\r\n<!--- Include as many relevant details about the environment you experienced the bug in -->\r\n\r\n| software         | version(s)\r\n| ---------------- | -------\r\n| Babel            |  6.26.0\r\n| Babylon          | <!-- This is only needed if you are using Babylon directly -->\r\n| node             | 8.11.1\r\n| npm              | 5.6.0\r\n| Operating System | High Sierra \r\n"}}
{"actor":{"display_login":"loganfsmyth"}}