<blockquote>
<p dir="auto">Issue originally made by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/Lapixx/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/Lapixx">@Lapixx</a></p>
</blockquote>
<h3 dir="auto">Bug information</h3>
<ul dir="auto">
<li><strong>Babel version:</strong> 6.7.7</li>
<li><strong>Node version:</strong> 5.3.0</li>
<li><strong>npm version:</strong> 3.3.12</li>
</ul>
<h3 dir="auto">Options</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ES2015 and Stage 0 preset."><pre class="notranslate"><code class="notranslate">ES2015 and Stage 0 preset.
</code></pre></div>
<h3 dir="auto">Input code</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// modified from kadirahq/graphql-errors

const modifyResolver = (field, handler) =&gt; {

  const originalResolve = field.resolve;

  field.resolve = async (...args) =&gt; { // Workaround 1: use `async function(...args) {`

    try {
      // const b = args; // Workaround 2: Access args -- even when unused.
      const res = originalResolve(...args); // Problem: arguments is undefined here
      return await Promise.resolve(res);
    }
    catch (err) {
      throw handler(err);
    }
  };
};"><pre class="notranslate"><code class="notranslate">// modified from kadirahq/graphql-errors

const modifyResolver = (field, handler) =&gt; {

  const originalResolve = field.resolve;

  field.resolve = async (...args) =&gt; { // Workaround 1: use `async function(...args) {`

    try {
      // const b = args; // Workaround 2: Access args -- even when unused.
      const res = originalResolve(...args); // Problem: arguments is undefined here
      return await Promise.resolve(res);
    }
    catch (err) {
      throw handler(err);
    }
  };
};
</code></pre></div>
<h3 dir="auto">Description</h3>
<p dir="auto">Basically, when I try to define a function like so:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const myFunc = async (...args) =&gt; {
    otherFunc(...args);
};"><pre class="notranslate"><code class="notranslate">const myFunc = async (...args) =&gt; {
    otherFunc(...args);
};
</code></pre></div>
<p dir="auto">The arguments are undefined. When you look at the output you can clearly see that <code class="notranslate">arguments</code> gets assigned outside of the function scope. I'm not sure why that happens. Removing <code class="notranslate">async</code> fixes the problem, using the <code class="notranslate">function</code> keyword fixes the problem, and (my favourite), assigning <code class="notranslate">args</code> to a value (or otherwise accessing it) also fixes the problem.</p>
<p dir="auto">[[ https://babeljs.io/repl/#?evaluate=true&amp;lineWrap=false&amp;presets=es2015%2Creact%2Cstage-0&amp;experimental=true&amp;loose=false&amp;spec=false&amp;code=%2F%2F%20modified%20from%20kadirahq%2Fgraphql-errors%0A%0Aconst%20modifyResolver%20%3D%20(field%2C%20handler)%20%3D%3E%20%7B%0A%20%20%0A%20%20const%20originalResolve%20%3D%20field.resolve%3B%0A%20%20%0A%20%20field.resolve%20%3D%20async%20(...args)%20%3D%3E%20%7B%20%2F%2F%20Workaround%201%3A%20use%20%60async%20function(...args)%20%7B%60%0A%0A%20%20%20%20try%20%7B%0A%20%20%20%20%20%20%2F%2F%20const%20b%20%3D%20args%3B%20%2F%2F%20Workaround%202%3A%20Access%20args%20--%20even%20when%20unused.%0A%20%20%20%20%20%20const%20res%20%3D%20originalResolve(...args)%3B%20%2F%2F%20Problem%3A%20arguments%20is%20undefined%20here%0A%20%20%20%20%20%20return%20await%20Promise.resolve(res)%3B%0A%20%20%20%20%7D%0A%20%20%20%20catch%20(err)%20%7B%0A%20%20%20%20%20%20throw%20handler(err)%3B%0A%20%20%20%20%7D%0A%20%20%7D%3B%0A%7D%3B | REPL with sample code ]]</p>
<blockquote>
<p dir="auto">Issue originally made by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/spudly/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/spudly">@spudly</a></p>
</blockquote>
<h3 dir="auto">Options</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="preset-es2015, preset-stage-3"><pre class="notranslate"><code class="notranslate">preset-es2015, preset-stage-3
</code></pre></div>
<h3 dir="auto">Input code</h3>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const callTest = async (...args) =&gt; {
    await test(...args);
  };

  const test = (arg) =&gt; console.log(arg);

  callTest('yo');"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-en">callTest</span> <span class="pl-c1">=</span> <span class="pl-k">async</span> <span class="pl-kos">(</span>...<span class="pl-s1">args</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">await</span> <span class="pl-en">test</span><span class="pl-kos">(</span>...<span class="pl-s1">args</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span><span class="pl-kos">;</span>

  <span class="pl-k">const</span> <span class="pl-en">test</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-s1">arg</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</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-s1">arg</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-en">callTest</span><span class="pl-kos">(</span><span class="pl-s">'yo'</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<h3 dir="auto">Description</h3>
<p dir="auto">This is similar to: T2776: Generators and async functions with default args place _this and _arguments incorrectly.</p>
<p dir="auto">When you use an async arrow function that uses a rest arg and then spread the resulting array into another function call without first accessing the variable, the _arguments variable is placed outside of the function, causing it to send the wrong arguments.</p>
<p dir="auto">Simply accessing the variable fixes this issue. All I have to do is add "args;" as the first line in the callTest() function and it starts working.</p>
<p dir="auto">Tested with the REPL at babeljs.io, version 6.7.4.</p>