<blockquote>
<p dir="auto">Issue originally made by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/bergus/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/bergus">@bergus</a></p>
</blockquote>
<h3 dir="auto">Bug information</h3>
<ul dir="auto">
<li><strong>Babel version:</strong> v6.x (babel.io/repl)</li>
</ul>
<h3 dir="auto">Options</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="plain preset es-2015, nothing else"><pre class="notranslate"><code class="notranslate">plain preset es-2015, nothing else
</code></pre></div>
<h3 dir="auto">Input code</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;
function foo1() {
  for (let bar = 2; bar &lt; 3; bar++) {
    let bar = 4;
  }
}
function foo2() {
  var bar;
  for (let bar = 2; bar &lt; 3; bar++) {
    let bar = 4;
  }
}"><pre class="notranslate"><code class="notranslate">"use strict";
function foo1() {
  for (let bar = 2; bar &lt; 3; bar++) {
    let bar = 4;
  }
}
function foo2() {
  var bar;
  for (let bar = 2; bar &lt; 3; bar++) {
    let bar = 4;
  }
}
</code></pre></div>
<p dir="auto">[[ https://babeljs.io/repl/#?evaluate=true&amp;lineWrap=false&amp;presets=es2015&amp;code="use%20strict"%3Bfunction%20foo1()%20{%20%20for%20(let%20bar%20%3D%202%3B%20bar%20&lt;%203%3B%20bar%2B%2B)%20{%20%20%20%20let%20bar%20%3D%204%3B%20%20}}function%20foo2()%20{%20%20var%20bar%3B%20%20for%20(let%20bar%20%3D%202%3B%20bar%20&lt;%203%3B%20bar%2B%2B)%20{%20%20%20%20let%20bar%20%3D%204%3B%20%20}} | produces ]]</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;

function foo1() {
  for (var bar = 2; bar &lt; 3; bar++) {
    var bar = 4;
  }
}
function foo2() {
  var bar;
  for (var bar = 2; bar &lt; 3; bar++) {
    var _bar = 4;
  }
}"><pre class="notranslate"><code class="notranslate">"use strict";

function foo1() {
  for (var bar = 2; bar &lt; 3; bar++) {
    var bar = 4;
  }
}
function foo2() {
  var bar;
  for (var bar = 2; bar &lt; 3; bar++) {
    var _bar = 4;
  }
}
</code></pre></div>
<h3 dir="auto">Description</h3>
<p dir="auto">In <code class="notranslate">foo1</code> it should produce two different <code class="notranslate">bar</code> variables - the one in the body of the loop is block-scoped and not the same as the one created by the loop. See also <a href="http://stackoverflow.com/q/37855990/1048572" rel="nofollow">http://stackoverflow.com/q/37855990/1048572</a></p>
<p dir="auto">Now that might be a simple bug, but it's getting weird in <code class="notranslate">foo2</code> where a function-level <code class="notranslate">bar</code> is introduced (both <code class="notranslate">let</code> and <code class="notranslate">var</code> and parameters reproduce this). Here the <code class="notranslate">bar</code> variables of the loop and the body are indeed separated as expected, but the one of the loop header collides with the function-scope one. This does usually work - as long as there is no <code class="notranslate">let</code> declaration in the loop body.</p>
<blockquote>
<p dir="auto">Issue originally reported by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/Faithree/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/Faithree">@Faithree</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="259720195" data-permission-text="Title is private" data-url="https://github.com/babel/babel-preset-env/issues/422" data-hovercard-type="issue" data-hovercard-url="/babel/babel-preset-env/issues/422/hovercard" href="https://github.com/babel/babel-preset-env/issues/422">babel/babel-preset-env#422</a></p>
</blockquote>
<p dir="auto">Somebody tell me how to do it? In addition to using polyfill</p>