title: Transpiled code throws error when masking a parameter with an object variable
body: <p>We tried to port the following code to ES6:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function apitest(data) {
      data.cb(true);
  }
  
  function test(cb) {
      apitest({cb: function(data) {
          commit(cb,data);
      }});
  
      function commit(cb,data) {
          cb(data);
      }
  }
  
  test(data =&gt; {
      document.write(data);
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>It might look a little confusing, but it does what we expect (return true) and does not throw errors.</p>
  
  <p>However, Babel transpiles it to:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>"use strict";
  
  function apitest(data) {
      data.cb(true);
  }
  
  function test(_cb) {
      apitest({ cb: function cb(data) {
              commit(_cb, data);
          } });
  
      function commit(_cb, data) {
          cb(data);
      }
  }
  
  test(function (data) {
      document.write(data);
  });
  
  //# sourceMappingURL=test4.js.map</code></pre>
  </div>
  </div>
  </p>
  
  <p>This code fails since the <code>cb()</code> called inside <code>commit()</code> does not have an underscore.</p>
  
  <p>Regardless of whether you should write this kind of code: Is our syntax faulty or is this a bug in Babel?</p>
  
  <p>My understanding is that the definition of <code>cb</code> inside the object should mask the passed parameter. Babel assigns different names to the variable used in the object and in the enclosing function while giving a name to the anonymous function (why would it do that anyway?). After that, it should rename the function call inside <code>commit()</code>.</p>