<p dir="auto">This code worked with babel 5.x and doesn't with babel 6.x. The expectation is that countdown1 and countdown2 both produce the same results:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="'use strict';

function sleep(timeout) {
  return new Promise(function (resolve, reject) {
    setTimeout(function () {
      resolve();
    }, timeout);
  });
}

const countdown1 = async function (count) {
  console.log(count);
  await sleep(1000);
  if (--count) {
    await countdown1(count);
  }
};

async function countdown2(count) {
  console.log(count);
  await sleep(1000);
  if (--count) {
    await countdown2(count);
  }
};

countdown1(5)
  .then(function () {
    console.log('countdown1 done');
    return countdown2(5);
  })
  .then(function () {
    console.log('countdown2 done');
  });"><pre class="notranslate"><code class="notranslate">'use strict';

function sleep(timeout) {
  return new Promise(function (resolve, reject) {
    setTimeout(function () {
      resolve();
    }, timeout);
  });
}

const countdown1 = async function (count) {
  console.log(count);
  await sleep(1000);
  if (--count) {
    await countdown1(count);
  }
};

async function countdown2(count) {
  console.log(count);
  await sleep(1000);
  if (--count) {
    await countdown2(count);
  }
};

countdown1(5)
  .then(function () {
    console.log('countdown1 done');
    return countdown2(5);
  })
  .then(function () {
    console.log('countdown2 done');
  });
</code></pre></div>
<p dir="auto">From the produced code, it looks like the transformed countdown2 is getting shadowed by inner functions using the same name.</p>
<p dir="auto">If named async function recursively calls itself by name then the compiled code is wrong.<br>
Workaround is to assign anonymous async function to a variable and do recursive calls via that variable.</p>
<p dir="auto">Problematic code:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="async function x( a ) { if ( a ) return a; else return await x( 42 ); }
x().then( a =&gt; console.log( a ) )"><pre class="notranslate"><span class="pl-k">async</span> <span class="pl-k">function</span> <span class="pl-en">x</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">if</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">a</span><span class="pl-kos">;</span> <span class="pl-k">else</span> <span class="pl-k">return</span> <span class="pl-k">await</span> <span class="pl-en">x</span><span class="pl-kos">(</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-en">x</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span> <span class="pl-s1">a</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">a</span> <span class="pl-kos">)</span> <span class="pl-kos">)</span></pre></div>
<p dir="auto">Output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt; GeneratorFunctionPrototype { _invoke: [Function: invoke] }"><pre class="notranslate"><code class="notranslate">&gt; GeneratorFunctionPrototype { _invoke: [Function: invoke] }
</code></pre></div>
<p dir="auto">But:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const x = async function ( a ) { if ( a ) return a; else return await x( 42 ); }
x().then( a =&gt; console.log( a ) )"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-en">x</span> <span class="pl-c1">=</span> <span class="pl-k">async</span> <span class="pl-k">function</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">if</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">a</span><span class="pl-kos">;</span> <span class="pl-k">else</span> <span class="pl-k">return</span> <span class="pl-k">await</span> <span class="pl-en">x</span><span class="pl-kos">(</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-en">x</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span> <span class="pl-s1">a</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">a</span> <span class="pl-kos">)</span> <span class="pl-kos">)</span></pre></div>
<p dir="auto">Output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt; 42"><pre class="notranslate"><code class="notranslate">&gt; 42
</code></pre></div>