{"action":"opened","issue":{"url":"https://api.github.com/repos/babel/babili/issues/485","repository_url":"https://api.github.com/repos/babel/babili","labels_url":"https://api.github.com/repos/babel/babili/issues/485/labels{/name}","comments_url":"https://api.github.com/repos/babel/babili/issues/485/comments","events_url":"https://api.github.com/repos/babel/babili/issues/485/events","html_url":"https://github.com/babel/babili/issues/485","id":218404887,"number":485,"title":"'let' causing variables to disappear in for-loop","user":{"login":"michaelmcleodnz","id":9371324,"avatar_url":"https://avatars3.githubusercontent.com/u/9371324?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelmcleodnz","html_url":"https://github.com/michaelmcleodnz","followers_url":"https://api.github.com/users/michaelmcleodnz/followers","following_url":"https://api.github.com/users/michaelmcleodnz/following{/other_user}","gists_url":"https://api.github.com/users/michaelmcleodnz/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelmcleodnz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelmcleodnz/subscriptions","organizations_url":"https://api.github.com/users/michaelmcleodnz/orgs","repos_url":"https://api.github.com/users/michaelmcleodnz/repos","events_url":"https://api.github.com/users/michaelmcleodnz/events{/privacy}","received_events_url":"https://api.github.com/users/michaelmcleodnz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-31T05:54:18Z","updated_at":"2017-03-31T05:54:18Z","closed_at":null,"body":"This only occurs in conjunction with the es2015 plugin.\r\nThe following code\r\n```javascript\r\nfunction getSum(data) {\r\n  let total = 0;\r\n  for (let i = 0; i < data.length; i++) {\r\n    total += data[i];\r\n  }\r\n  return total;\r\n}\r\n```\r\ngets transpiled to\r\n```javascript\r\n\"use strict\";function getSum(a){for(var c=0;c<a.length;c++)a[c];return b}\r\n```\r\nwhich returns the undefined variable `b`. Seemingly `total` has been removed.\r\n\r\nThe same code using `var i` instead of `let i` produces the expected result\r\n```javascript\r\n\"use strict\";function getSum(a){for(var c=0,b=0;b<a.length;b++)c+=a[b];return c}\r\n```"}}
{"actor":{"display_login":"michaelmcleodnz"}}