<p dir="auto">Bug is reproducible in Babel 5.x REPL. I wasn't able to test it with Babel 6, sorry.</p>
<p dir="auto"><a href="https://babeljs.io/repl/#?experimental=true&amp;evaluate=true&amp;loose=false&amp;spec=true&amp;playground=true&amp;code=function%20composeSync%28f%2C%20g%29%20%7B%0A%20%20return%20%28...args%29%20%3D%3E%20f%28g%28...args%29%29%3B%0A%7D%0A%0Afunction%20composeAsync%28f%2C%20g%29%20%7B%0A%20%20return%20async%20%28...args%29%20%3D%3E%20f%28await%20g%28...args%29%29%3B%0A%7D%0A" rel="nofollow">Code example</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="function composeSync(f, g) {
  return (...args) =&gt; f(g(...args));
}

function composeAsync(f, g) {
  return async (...args) =&gt; f(await g(...args));
}"><pre class="notranslate"><code class="notranslate">function composeSync(f, g) {
  return (...args) =&gt; f(g(...args));
}

function composeAsync(f, g) {
  return async (...args) =&gt; f(await g(...args));
}
</code></pre></div>
<p dir="auto">In first function everything is good: the result of <code class="notranslate">composeSync</code> will be an arrow function which uses rest operator for getting all arguments.</p>
<p dir="auto">In the <code class="notranslate">composeAsync</code> function behavior is different (maybe because of regenerator's runtime?): arguments for rest operator are taken from outer scope, from <code class="notranslate">composeAsync</code> function.</p>
<p dir="auto">Any thoughts?</p>
<p dir="auto">Choose one: bug report</p>
<p dir="auto">The error message</p>
<blockquote>
<p dir="auto">TypeError: test.js: Duplicate declaration "tmp" (This is an error on an internal node. Probably an internal error.)</p>
</blockquote>
<p dir="auto">is shown when transpiling the input code. node successfully executes the input code.</p>
<h3 dir="auto">Input Code</h3>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="async function foo() {
	(async function (number) {
		const tmp = number
	})
}"><pre class="notranslate"><span class="pl-k">async</span> <span class="pl-k">function</span> <span class="pl-en">foo</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">async</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">number</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
		<span class="pl-k">const</span> <span class="pl-s1">tmp</span> <span class="pl-c1">=</span> <span class="pl-s1">number</span>
	<span class="pl-kos">}</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span></pre></div>
<h3 dir="auto">Babel/Babylon Configuration (.babelrc, package.json, cli command)</h3>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{ &quot;presets&quot;: [ [ &quot;@babel/env&quot;
               , { &quot;targets&quot;: { &quot;browsers&quot;: [ &quot;last 2 chrome versions&quot;
                                            , &quot;last 2 chromeandroid versions&quot;
                                            , &quot;firefox esr&quot;
                                            , &quot;last 2 firefox versions&quot;
                                            , &quot;edge &gt;= 15&quot;
                                            , &quot;safari &gt;= 11&quot;
                                            ]
                              }
                 , &quot;debug&quot;: true
                 }
               ]
             ]
}"><pre class="notranslate"><span class="pl-kos">{</span> <span class="pl-s">"presets"</span>: <span class="pl-kos">[</span> <span class="pl-kos">[</span> <span class="pl-s">"@babel/env"</span>
               <span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-s">"targets"</span>: <span class="pl-kos">{</span> <span class="pl-s">"browsers"</span>: <span class="pl-kos">[</span> <span class="pl-s">"last 2 chrome versions"</span>
                                            <span class="pl-kos">,</span> <span class="pl-s">"last 2 chromeandroid versions"</span>
                                            <span class="pl-kos">,</span> <span class="pl-s">"firefox esr"</span>
                                            <span class="pl-kos">,</span> <span class="pl-s">"last 2 firefox versions"</span>
                                            <span class="pl-kos">,</span> <span class="pl-s">"edge &gt;= 15"</span>
                                            <span class="pl-kos">,</span> <span class="pl-s">"safari &gt;= 11"</span>
                                            <span class="pl-kos">]</span>
                              <span class="pl-kos">}</span>
                 <span class="pl-kos">,</span> <span class="pl-s">"debug"</span>: <span class="pl-c1">true</span>
                 <span class="pl-kos">}</span>
               <span class="pl-kos">]</span>
             <span class="pl-kos">]</span>
<span class="pl-kos">}</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;dependencies&quot;: {
    &quot;@babel/cli&quot;: &quot;^7.0.0-beta.32&quot;,
    &quot;@babel/core&quot;: &quot;^7.0.0-beta.32&quot;,
    &quot;@babel/preset-env&quot;: &quot;^7.0.0-beta.32&quot;,
    &quot;regenerator-runtime&quot;: &quot;^0.11.0&quot;
  }
}"><pre class="notranslate"><span class="pl-kos">{</span>
  <span class="pl-s">"dependencies"</span>: <span class="pl-kos">{</span>
    <span class="pl-s">"@babel/cli"</span>: <span class="pl-s">"^7.0.0-beta.32"</span><span class="pl-kos">,</span>
    <span class="pl-s">"@babel/core"</span>: <span class="pl-s">"^7.0.0-beta.32"</span><span class="pl-kos">,</span>
    <span class="pl-s">"@babel/preset-env"</span>: <span class="pl-s">"^7.0.0-beta.32"</span><span class="pl-kos">,</span>
    <span class="pl-s">"regenerator-runtime"</span>: <span class="pl-s">"^0.11.0"</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">The script is successfully transpiled.</p>
<h3 dir="auto">Current Behavior</h3>
<p dir="auto">The given error message appears:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="root@3f46f465fd04:/pwd# yarn run babel test.js
yarn run v1.3.2
warning package.json: No license field
$ /pwd/node_modules/.bin/babel test.js
@babel/preset-env: `DEBUG` option

Using targets:
{
  &quot;chrome&quot;: &quot;61&quot;,
  &quot;edge&quot;: &quot;15&quot;,
  &quot;firefox&quot;: &quot;52&quot;,
  &quot;safari&quot;: &quot;11&quot;
}

Using modules transform: commonjs

Using plugins:
  transform-destructuring { &quot;edge&quot;:&quot;15&quot;, &quot;firefox&quot;:&quot;52&quot; }
  transform-for-of { &quot;firefox&quot;:&quot;52&quot; }
  transform-function-name { &quot;edge&quot;:&quot;15&quot;, &quot;firefox&quot;:&quot;52&quot; }
  transform-literals { &quot;firefox&quot;:&quot;52&quot; }
  transform-parameters { &quot;firefox&quot;:&quot;52&quot; }
  transform-regenerator { &quot;firefox&quot;:&quot;52&quot; }

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
TypeError: test.js: Duplicate declaration &quot;tmp&quot; (This is an error on an internal node. Probably an internal error.)
    at File.buildCodeFrameError (/pwd/node_modules/@babel/core/lib/transformation/file/file.js:209:12)
    at Scope.checkBlockScopedCollisions (/pwd/node_modules/@babel/traverse/lib/scope/index.js:295:27)
    at Scope.registerBinding (/pwd/node_modules/@babel/traverse/lib/scope/index.js:477:16)
    at Scope.registerDeclaration (/pwd/node_modules/@babel/traverse/lib/scope/index.js:396:14)
    at Object.Declaration (/pwd/node_modules/@babel/traverse/lib/scope/index.js:89:12)
    at NodePath._call (/pwd/node_modules/@babel/traverse/lib/path/context.js:64:19)
    at NodePath.call (/pwd/node_modules/@babel/traverse/lib/path/context.js:38:17)
    at NodePath.visit (/pwd/node_modules/@babel/traverse/lib/path/context.js:95:12)
    at TraversalContext.visitQueue (/pwd/node_modules/@babel/traverse/lib/context.js:139:18)
    at TraversalContext.visitMultiple (/pwd/node_modules/@babel/traverse/lib/context.js:93:17)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command."><pre class="notranslate"><code class="notranslate">root@3f46f465fd04:/pwd# yarn run babel test.js
yarn run v1.3.2
warning package.json: No license field
$ /pwd/node_modules/.bin/babel test.js
@babel/preset-env: `DEBUG` option

Using targets:
{
  "chrome": "61",
  "edge": "15",
  "firefox": "52",
  "safari": "11"
}

Using modules transform: commonjs

Using plugins:
  transform-destructuring { "edge":"15", "firefox":"52" }
  transform-for-of { "firefox":"52" }
  transform-function-name { "edge":"15", "firefox":"52" }
  transform-literals { "firefox":"52" }
  transform-parameters { "firefox":"52" }
  transform-regenerator { "firefox":"52" }

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
TypeError: test.js: Duplicate declaration "tmp" (This is an error on an internal node. Probably an internal error.)
    at File.buildCodeFrameError (/pwd/node_modules/@babel/core/lib/transformation/file/file.js:209:12)
    at Scope.checkBlockScopedCollisions (/pwd/node_modules/@babel/traverse/lib/scope/index.js:295:27)
    at Scope.registerBinding (/pwd/node_modules/@babel/traverse/lib/scope/index.js:477:16)
    at Scope.registerDeclaration (/pwd/node_modules/@babel/traverse/lib/scope/index.js:396:14)
    at Object.Declaration (/pwd/node_modules/@babel/traverse/lib/scope/index.js:89:12)
    at NodePath._call (/pwd/node_modules/@babel/traverse/lib/path/context.js:64:19)
    at NodePath.call (/pwd/node_modules/@babel/traverse/lib/path/context.js:38:17)
    at NodePath.visit (/pwd/node_modules/@babel/traverse/lib/path/context.js:95:12)
    at TraversalContext.visitQueue (/pwd/node_modules/@babel/traverse/lib/context.js:139:18)
    at TraversalContext.visitMultiple (/pwd/node_modules/@babel/traverse/lib/context.js:93:17)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
</code></pre></div>
<h3 dir="auto">Possible Solution</h3>
<h3 dir="auto">Context</h3>
<p dir="auto">It worked fine with <code class="notranslate">babel-preset-env</code> in version <code class="notranslate">1.5.2</code>. It is broken with <code class="notranslate">@babel/preset-env</code> in version <code class="notranslate">7.0.0-beta.32</code>.</p>
<h3 dir="auto">Your Environment</h3>

<table role="table">
<thead>
<tr>
<th>software</th>
<th>version(s)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Babel</td>
<td>7.0.0-beta.32 (@babel/core 7.0.0-beta.32)</td>
</tr>
<tr>
<td>Babylon</td>
<td></td>
</tr>
<tr>
<td>node</td>
<td>v9.2.0</td>
</tr>
<tr>
<td>npm</td>
<td>5.5.1</td>
</tr>
<tr>
<td>Operating System</td>
<td>Official node.js Docker container</td>
</tr>
</tbody>
</table>