<p dir="auto">Hi,</p>
<p dir="auto"><a href="https://babeljs.io/repl/#?experimental=true&amp;evaluate=false&amp;loose=false&amp;spec=false&amp;code=async%20function%20test%28%20%7B%20a%20%7D%20%3D%20%7B%20%7D%20%29%20%7B%0A%20%20alert%28%20a%20%29%3B%0A%20%20alert%28%20arguments%20%29%3B%0A%7D%0A%0Atest%28%20%7B%20a%20%3A%2010%20%7D%20%29%3B%0A" rel="nofollow">(demo)</a></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="async function test( { a } = { } ) {
  alert( a );
  alert( arguments );
}

test( { a : 10 } );"><pre class="notranslate"><span class="pl-k">async</span> <span class="pl-k">function</span> <span class="pl-en">test</span><span class="pl-kos">(</span> <span class="pl-kos">{</span> a <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-kos">}</span> <span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-en">alert</span><span class="pl-kos">(</span> <span class="pl-s1">a</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-en">alert</span><span class="pl-kos">(</span> <span class="pl-smi">arguments</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-en">test</span><span class="pl-kos">(</span> <span class="pl-kos">{</span> <span class="pl-c1">a</span> : <span class="pl-c1">10</span> <span class="pl-kos">}</span> <span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Babel will alert undefined, because the destructuring parameters are evaluated inside the regenerator wrapper, which doesn't preserve the <code class="notranslate">arguments</code> variable. Actually, any use of <code class="notranslate">arguments</code> inside the body of an async function will fail.</p>
<p dir="auto">Here's the code snippet:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const x = ({ a = 1 } = {}) =&gt; a

console.log(x()) // 1
console.log(x({})) // 1
console.log(x({ a: 5 })) // 5

const y = async ({ a = 1 } = {}) =&gt; a

async () =&gt; {
  console.log(await y()) // 1
  console.log(await y({})) // 1
  console.log(await y({ a: 5 })) // 1 (expected 5)
}()"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-en">x</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> a <span class="pl-c1">=</span> <span class="pl-c1">1</span> <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">a</span>

<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-c">// 1</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-c">// 1</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">a</span>: <span class="pl-c1">5</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-c">// 5</span>

<span class="pl-k">const</span> <span class="pl-en">y</span> <span class="pl-c1">=</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> a <span class="pl-c1">=</span> <span class="pl-c1">1</span> <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">a</span>

<span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-k">await</span> <span class="pl-en">y</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-c">// 1</span>
  <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-k">await</span> <span class="pl-en">y</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-c">// 1</span>
  <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-k">await</span> <span class="pl-en">y</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">a</span>: <span class="pl-c1">5</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-c">// 1 (expected 5)</span>
<span class="pl-kos">}</span><span class="pl-kos">(</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">Using Babel 4.7.12 (experimental mode).</p>
<p dir="auto">Works without the <code class="notranslate">= {}</code>, but then it don't allow passing no argument to the function.</p>
<p dir="auto">The above snippet was compiled as (for just the <code class="notranslate">y</code> function):</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=" var y = function callee$0$0() {
   var _ref, _ref$a, a;

   return _regeneratorRuntime.async(function callee$0$0$(context$1$0) {
     while (1) switch (context$1$0.prev = context$1$0.next) {
       case 0:
         _ref = arguments[0] === undefined ? {} : arguments[0];
         _ref$a = _ref.a;
         a = _ref$a === undefined ? 1 : _ref$a;
         return context$1$0.abrupt(&quot;return&quot;, a);

       case 4:
       case &quot;end&quot;:
         return context$1$0.stop();
     }
   }, null, _this);
 };"><pre class="notranslate"> <span class="pl-k">var</span> <span class="pl-en">y</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-en">callee$0$0</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
   <span class="pl-k">var</span> <span class="pl-s1">_ref</span><span class="pl-kos">,</span> <span class="pl-s1">_ref$a</span><span class="pl-kos">,</span> <span class="pl-s1">a</span><span class="pl-kos">;</span>

   <span class="pl-k">return</span> <span class="pl-s1">_regeneratorRuntime</span><span class="pl-kos">.</span><span class="pl-en">async</span><span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-en">callee$0$0$</span><span class="pl-kos">(</span><span class="pl-s1">context$1$0</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
     <span class="pl-k">while</span> <span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">)</span> <span class="pl-k">switch</span> <span class="pl-kos">(</span><span class="pl-s1">context$1$0</span><span class="pl-kos">.</span><span class="pl-c1">prev</span> <span class="pl-c1">=</span> <span class="pl-s1">context$1$0</span><span class="pl-kos">.</span><span class="pl-c1">next</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
       <span class="pl-k">case</span> <span class="pl-c1">0</span>:
         <span class="pl-s1">_ref</span> <span class="pl-c1">=</span> <span class="pl-smi">arguments</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span> <span class="pl-c1">===</span> <span class="pl-c1">undefined</span> ? <span class="pl-kos">{</span><span class="pl-kos">}</span> : <span class="pl-smi">arguments</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
         <span class="pl-s1">_ref$a</span> <span class="pl-c1">=</span> <span class="pl-s1">_ref</span><span class="pl-kos">.</span><span class="pl-c1">a</span><span class="pl-kos">;</span>
         <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">_ref$a</span> <span class="pl-c1">===</span> <span class="pl-c1">undefined</span> ? <span class="pl-c1">1</span> : <span class="pl-s1">_ref$a</span><span class="pl-kos">;</span>
         <span class="pl-k">return</span> <span class="pl-s1">context$1$0</span><span class="pl-kos">.</span><span class="pl-en">abrupt</span><span class="pl-kos">(</span><span class="pl-s">"return"</span><span class="pl-kos">,</span> <span class="pl-s1">a</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

       <span class="pl-k">case</span> <span class="pl-c1">4</span>:
       <span class="pl-k">case</span> <span class="pl-s">"end"</span>:
         <span class="pl-k">return</span> <span class="pl-s1">context$1$0</span><span class="pl-kos">.</span><span class="pl-en">stop</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
     <span class="pl-kos">}</span>
   <span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">null</span><span class="pl-kos">,</span> <span class="pl-s1">_this</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
 <span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Looks like there's a problem using <code class="notranslate">arguments</code> in a generator function; here <code class="notranslate">arguments[0] === context$1$0</code>. I think the arguments destructuring should be just after <code class="notranslate">var _ref, _ref$a, a;</code>. I achieved this by moving <code class="notranslate">regenerator</code> around in <code class="notranslate">babel/transformation/transformers/index.js</code> (just before default parameters):</p>
<div class="highlight highlight-source-diff notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="diff --git a/index.old.js b/index.new.js
index 70cd878..f304e6f 100644
--- a/index.old.js
+++ b/index.new.js
@@ -61,6 +61,8 @@ module.exports = {
   // needs to be after `es6.parameters.rest` as we use `toArray` and avoid turning an already known arr
ay into one
   &quot;es6.spread&quot;: require(&quot;./es6/spread&quot;),

+  regenerator: require(&quot;./other/regenerator&quot;),
+
   // needs to be before `es6.blockScoping` as default parameters have a TDZ
   &quot;es6.parameters.default&quot;: require(&quot;./es6/parameters.default&quot;),

@@ -78,8 +80,6 @@ module.exports = {
   // identifiers in parameters and variable declarators
   &quot;es6.tailCall&quot;: require(&quot;./es6/tail-call&quot;),

-  regenerator: require(&quot;./other/regenerator&quot;),
-
   // needs to be after `regenerator` due to needing `regeneratorRuntime` references
   // needs to be after `es6.forOf` due to needing `Symbol.iterator` references
   // needs to be before `es6.modules` due to dynamic imports"><pre class="notranslate"><span class="pl-c1">diff --git a/index.old.js b/index.new.js</span>
index 70cd878..f304e6f 100644
<span class="pl-md">--- a/index.old.js</span>
<span class="pl-mi1">+++ b/index.new.js</span>
<span class="pl-mdr">@@ -61,6 +61,8 @@</span> module.exports = {
   // needs to be after `es6.parameters.rest` as we use `toArray` and avoid turning an already known arr
ay into one
   "es6.spread": require("./es6/spread"),

<span class="pl-mi1"><span class="pl-mi1">+</span>  regenerator: require("./other/regenerator"),</span>
<span class="pl-mi1"><span class="pl-mi1">+</span></span>
   // needs to be before `es6.blockScoping` as default parameters have a TDZ
   "es6.parameters.default": require("./es6/parameters.default"),

<span class="pl-mdr">@@ -78,8 +80,6 @@</span> module.exports = {
   // identifiers in parameters and variable declarators
   "es6.tailCall": require("./es6/tail-call"),

<span class="pl-md"><span class="pl-md">-</span>  regenerator: require("./other/regenerator"),</span>
<span class="pl-md"><span class="pl-md">-</span></span>
   // needs to be after `regenerator` due to needing `regeneratorRuntime` references
   // needs to be after `es6.forOf` due to needing `Symbol.iterator` references
   // needs to be before `es6.modules` due to dynamic imports</pre></div>