<blockquote>
<p dir="auto">Issue originally made by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ochafik/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ochafik">@ochafik</a></p>
</blockquote>
<h3 dir="auto">Bug information</h3>
<ul dir="auto">
<li><strong>Babel version:</strong> 6.1.1 (babel-core 6.0.20)</li>
<li><strong>Node version:</strong> 5.5.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="--presets es2015"><pre class="notranslate"><code class="notranslate">--presets es2015
</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="class Foo { foo() { let foo = 1 } }"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">Foo</span> <span class="pl-kos">{</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-k">let</span> <span class="pl-s1">foo</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span> <span class="pl-kos">}</span> <span class="pl-kos">}</span></pre></div>
<h3 dir="auto">Description</h3>
<p dir="auto">The following code causes a bug:</p>
<p dir="auto"><code class="notranslate">echo "class Foo { foo() { let foo = 1 } }" | babel --presets es2015</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TypeError: unknown: Duplicate declaration &quot;foo&quot;
&gt; 1 | class Foo { foo() { let foo = 1 } }"><pre class="notranslate"><code class="notranslate">TypeError: unknown: Duplicate declaration "foo"
&gt; 1 | class Foo { foo() { let foo = 1 } }
</code></pre></div>
<p dir="auto">Note that using <code class="notranslate">var</code> instead of <code class="notranslate">let</code> is fine:<br>
<code class="notranslate">echo "class Foo { foo() { var foo = 1 } }" | babel --presets es2015</code></p>
<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>Current Behavior</strong><br>
babel throws</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Duplicate declaration &quot;foo&quot; (This is an error on an internal node. Probably an internal error.)"><pre class="notranslate"><code class="notranslate">Duplicate declaration "foo" (This is an error on an internal node. Probably an internal error.)
</code></pre></div>
<p dir="auto"><strong>Input Code</strong></p>
<ul dir="auto">
<li>REPL or Repo link if applicable:</li>
</ul>
<p dir="auto"><a href="https://babeljs.io/repl#?babili=false&amp;browsers=Chrome%20%3E%3D%2045%2Clast%202%20Firefox%20versions%2Cie%20%3E%3D%209%2CEdge%20%3E%3D%2012%2CiOS%20%3E%3D%209%2CAndroid%20%3E%3D%204%2Clast%202%20ChromeAndroid%20versions&amp;build=&amp;builtIns=false&amp;spec=false&amp;loose=false&amp;code_lz=BQQwzgngdgxgBMAlHAvAPjgbwFBzw8aeJVDHffGAeyjABc4AzKq1OAFgCYBuXfAX0RI-g4XiA&amp;debug=false&amp;forceAllTransforms=false&amp;shippedProposals=false&amp;circleciRepo=&amp;evaluate=false&amp;fileSize=false&amp;timeTravel=false&amp;sourceType=module&amp;lineWrap=true&amp;presets=&amp;prettier=false&amp;targets=&amp;version=7.0.0-beta.34&amp;envVersion=7.0.0-beta.34" rel="nofollow">https://babeljs.io/repl#?babili=false&amp;browsers=Chrome%20%3E%3D%2045%2Clast%202%20Firefox%20versions%2Cie%20%3E%3D%209%2CEdge%20%3E%3D%2012%2CiOS%20%3E%3D%209%2CAndroid%20%3E%3D%204%2Clast%202%20ChromeAndroid%20versions&amp;build=&amp;builtIns=false&amp;spec=false&amp;loose=false&amp;code_lz=BQQwzgngdgxgBMAlHAvAPjgbwFBzw8aeJVDHffGAeyjABc4AzKq1OAFgCYBuXfAX0RI-g4XiA&amp;debug=false&amp;forceAllTransforms=false&amp;shippedProposals=false&amp;circleciRepo=&amp;evaluate=false&amp;fileSize=false&amp;timeTravel=false&amp;sourceType=module&amp;lineWrap=true&amp;presets=&amp;prettier=false&amp;targets=&amp;version=7.0.0-beta.34&amp;envVersion=7.0.0-beta.34</a></p>
<p dir="auto">Note: you have to manually add <code class="notranslate">@babel/transform-regenerator</code> 7.0.0 plugin since the url does not synchronize plugin selections.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="(async () =&gt; {
    (async () =&gt; {
      const foo = 42;
    })()
  })()
  "><pre class="notranslate"><span class="pl-kos">(</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-kos">(</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-k">const</span> <span class="pl-s1">foo</span> <span class="pl-c1">=</span> <span class="pl-c1">42</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-kos">)</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
  </pre></div>
<p dir="auto"><strong>Expected behavior/code</strong><br>
Compiled as regenerator calls</p>
<p dir="auto"><strong>Babel Configuration (.babelrc, package.json, cli command)</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="module.exports = {
    plugins: [
        &quot;@babel/transform-regenerator&quot;
    ]
}"><pre class="notranslate"><span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
    <span class="pl-c1">plugins</span>: <span class="pl-kos">[</span>
        <span class="pl-s">"@babel/transform-regenerator"</span>
    <span class="pl-kos">]</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><strong>Environment</strong></p>
<ul dir="auto">
<li>Babel version(s): v7.0.0</li>
<li>Node/npm version: Node 10</li>
<li>OS: macOS 10.14</li>
<li>Monorepo no</li>
<li>How you are using Babel: cli</li>
</ul>
<p dir="auto"><strong>Possible Solution</strong><br>
Workaround: add <code class="notranslate">await</code> to the nested async function.</p>
<p dir="auto"><strong>Additional context/Screenshots</strong><br>
Possibly related: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="353773136" data-permission-text="Title is private" data-url="https://github.com/babel/babel/issues/8525" data-hovercard-type="issue" data-hovercard-url="/babel/babel/issues/8525/hovercard" href="https://github.com/babel/babel/issues/8525">#8525</a></p>