<blockquote>
<p dir="auto">Issue originally made by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/decafdennis/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/decafdennis">@decafdennis</a></p>
</blockquote>
<h3 dir="auto">Bug information</h3>
<ul dir="auto">
<li><strong>Babel version:</strong> 6.7.2</li>
<li><strong>Node version:</strong> 5.0.0</li>
<li><strong>npm version:</strong> 3.3.9</li>
</ul>
<h3 dir="auto">Options</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
  &quot;plugins&quot;: [
    &quot;external-helpers&quot;,
    &quot;transform-es2015-parameters&quot;,
    &quot;transform-async-to-generator&quot;
  ]
}"><pre class="notranslate"><code class="notranslate">{
  "plugins": [
    "external-helpers",
    "transform-es2015-parameters",
    "transform-async-to-generator"
  ]
}
</code></pre></div>
<h3 dir="auto">Input code</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="function f() {
  g(async function() {
    c(() =&gt; this);
  });
}"><pre class="notranslate"><code class="notranslate">function f() {
  g(async function() {
    c(() =&gt; this);
  });
}
</code></pre></div>
<h3 dir="auto">Description</h3>
<p dir="auto">Expected output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="function f() {
  g(babelHelpers.asyncToGenerator(function* () {
    var _this = this;

    c(function () {
      return _this;
    });
  }));
}"><pre class="notranslate"><code class="notranslate">function f() {
  g(babelHelpers.asyncToGenerator(function* () {
    var _this = this;

    c(function () {
      return _this;
    });
  }));
}
</code></pre></div>
<p dir="auto">Actual output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="function f() {
  var _this = this;

  g(babelHelpers.asyncToGenerator(function* () {
    c(function () {
      return _this;
    });
  }));
}"><pre class="notranslate"><code class="notranslate">function f() {
  var _this = this;

  g(babelHelpers.asyncToGenerator(function* () {
    c(function () {
      return _this;
    });
  }));
}
</code></pre></div>
<p dir="auto">I [[ https://github.com/babel/babel/compare/master...getstreamline:fix-arrow-this-in-anonymous-function | started work on a fix ]] but I haven't been able to figure out what causes <code class="notranslate">_this</code> to scope differently. Interestingly, if in <code class="notranslate">babel-helper-remap-async-to-generator/src/index.js</code> I remove the <code class="notranslate">replaceWith(built)</code> call, then the lexical scope for <code class="notranslate">this</code> is fixed, but of course I'm missing the call to the helper.</p>
<p dir="auto">Version 6.23.0 of babel-transform causes babel-plugin-transform-es2015-destructuring to crash while compiling our app.</p>
<p dir="auto">Pinning to babel-tranform@6.22.1 removes the crash.</p>
<p dir="auto">If I console.log(this.hub) in babel-transform I see that this.hub is an empty object. This should be trivial to reproduce in any app that uses destructuring..</p>
<p dir="auto">TypeError: /Users/nick/git/app/src/server/server.js: this.hub.addHelper is not a function<br>
at Scope.toArray (/Users/nick/git/app/frontend/node_modules/babel-traverse/lib/scope/index.js:463:38)<br>
at DestructuringTransformer.toArray (/Users/nick/git/app/frontend/node_modules/babel-plugin-transform-es2015-destructuring/lib/index.js:122:27)<br>
at DestructuringTransformer.pushArrayPattern (/Users/nick/git/app/frontend/node_modules/babel-plugin-transform-es2015-destructuring/lib/index.js:277:26)<br>
at DestructuringTransformer.push (/Users/nick/git/app/frontend/node_modules/babel-plugin-transform-es2015-destructuring/lib/index.js:110:14)<br>
at DestructuringTransformer.init (/Users/nick/git/app/frontend/node_modules/babel-plugin-transform-es2015-destructuring/lib/index.js:317:12)<br>
at PluginPass.VariableDeclaration (/Users/nick/git/app/frontend/node_modules/babel-plugin-transform-es2015-destructuring/lib/index.js:468:27)<br>
at newFn (/Users/nick/git/app/frontend/node_modules/babel-traverse/lib/visitors.js:276:21)<br>
at NodePath._call (/Users/nick/git/app/frontend/node_modules/babel-traverse/lib/path/context.js:76:18)<br>
at NodePath.call (/Users/nick/git/app/frontend/node_modules/babel-traverse/lib/path/context.js:48:17)<br>
at NodePath.visit (/Users/nick/git/app/frontend/node_modules/babel-traverse/lib/path/context.js:105:12)</p>