<p dir="auto">Spread operator does not work when run with native promises in Chrome:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let args = [(Yeah, Nah) =&gt; Yeah()]
let promise = new Promise(...args)"><pre class="notranslate"><span class="pl-k">let</span> <span class="pl-s1">args</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">(</span><span class="pl-v">Yeah</span><span class="pl-kos">,</span> <span class="pl-v">Nah</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-v">Yeah</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">promise</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">Promise</span><span class="pl-kos">(</span>...<span class="pl-s1">args</span><span class="pl-kos">)</span></pre></div>
<blockquote>
<p dir="auto">Uncaught TypeError: [object Object] is not a promise</p>
</blockquote>
<p dir="auto"><a href="https://babeljs.io/repl/#?experimental=true&amp;playground=false&amp;evaluate=true&amp;loose=false&amp;spec=false&amp;code=let%20args%20%3D%20%5B(Yeah%2C%20Nah)%20%3D%3E%20Yeah()%5D%0Alet%20promise%20%3D%20new%20Promise(...args)" rel="nofollow">https://babeljs.io/repl/#?experimental=true&amp;playground=false&amp;evaluate=true&amp;loose=false&amp;spec=false&amp;code=let%20args%20%3D%20%5B(Yeah%2C%20Nah)%20%3D%3E%20Yeah()%5D%0Alet%20promise%20%3D%20new%20Promise(...args)</a></p>
<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>Current Behavior</strong><br>
Transpilation of the code fails with the following error.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TypeError: .../babel-duplicate-definition-error/index.js: Duplicate declaration &quot;Foo&quot;
  3 | export default function wrap() {
  4 |   return function() {
&gt; 5 |           class Foo {
    |                 ^
  6 |                   @autobind
  7 |                   method() {}
  8 |           }
    at File.buildCodeFrameError (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/core/lib/transformation/file/file.js:259:12)
    at Scope.checkBlockScopedCollisions (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/scope/index.js:347:22)
    at Scope.registerBinding (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/scope/index.js:504:16)
    at Scope.registerDeclaration (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/scope/index.js:444:14)
    at Object.BlockScoped (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/scope/index.js:189:28)
    at Object.newFn (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/visitors.js:230:17)
    at NodePath._call (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/path/context.js:36:14)
    at NodePath.visit (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/path/context.js:88:12)
    at TraversalContext.visitQueue (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/context.js:118:16)"><pre class="notranslate"><code class="notranslate">TypeError: .../babel-duplicate-definition-error/index.js: Duplicate declaration "Foo"
  3 | export default function wrap() {
  4 |   return function() {
&gt; 5 |           class Foo {
    |                 ^
  6 |                   @autobind
  7 |                   method() {}
  8 |           }
    at File.buildCodeFrameError (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/core/lib/transformation/file/file.js:259:12)
    at Scope.checkBlockScopedCollisions (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/scope/index.js:347:22)
    at Scope.registerBinding (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/scope/index.js:504:16)
    at Scope.registerDeclaration (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/scope/index.js:444:14)
    at Object.BlockScoped (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/scope/index.js:189:28)
    at Object.newFn (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/visitors.js:230:17)
    at NodePath._call (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/path/context.js:36:14)
    at NodePath.visit (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/path/context.js:88:12)
    at TraversalContext.visitQueue (/private/tmp/babel-duplicate-definition-error/node_modules/@babel/traverse/lib/context.js:118:16)
</code></pre></div>
<p dir="auto"><strong>Input Code</strong><br>
Executable gist: <a href="https://gist.github.com/dantman/81ab0e3f823ce287d1bd8b2a65b4ad52">https://gist.github.com/dantman/81ab0e3f823ce287d1bd8b2a65b4ad52</a></p>
<ul dir="auto">
<li>Must use <code class="notranslate">@babel/preset-env</code> with a target like <code class="notranslate">node: 8</code></li>
<li>Must use <code class="notranslate">@babel/plugin-proposal-decorators</code> with <code class="notranslate">legacy: true</code></li>
</ul>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import {autobind} from 'core-decorators';

export default function wrap() {
	return function() {
		class Foo {
			@autobind
			method() {}
		}

		return Foo;
	};
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span><span class="pl-s1">autobind</span><span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'core-decorators'</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-k">function</span> <span class="pl-en">wrap</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
	<span class="pl-k">return</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
		<span class="pl-k">class</span> <span class="pl-v">Foo</span> <span class="pl-kos">{</span>
			@<span class="pl-s1">autobind</span>
			<span class="pl-en">method</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-k">return</span> <span class="pl-v">Foo</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>
A clear and concise description of what you expected to happen (or code).</p>
<p dir="auto"><strong>Babel Configuration (.babelrc, package.json, cli command)</strong></p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;presets&quot;: [
    [
      &quot;@babel/preset-env&quot;,
      {
        &quot;targets&quot;: {
          &quot;node&quot;: 8
        }
      }
    ]
  ],
  &quot;plugins&quot;: [
    [&quot;@babel/plugin-proposal-decorators&quot;, {&quot;legacy&quot;: true}]
  ]	
}"><pre class="notranslate">{
  <span class="pl-ent">"presets"</span>: [
    [
      <span class="pl-s"><span class="pl-pds">"</span>@babel/preset-env<span class="pl-pds">"</span></span>,
      {
        <span class="pl-ent">"targets"</span>: {
          <span class="pl-ent">"node"</span>: <span class="pl-c1">8</span>
        }
      }
    ]
  ],
  <span class="pl-ent">"plugins"</span>: [
    [<span class="pl-s"><span class="pl-pds">"</span>@babel/plugin-proposal-decorators<span class="pl-pds">"</span></span>, {<span class="pl-ent">"legacy"</span>: <span class="pl-c1">true</span>}]
  ]	
}</pre></div>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;scripts&quot;: {
    &quot;start&quot;: &quot;babel index.js&quot;
  },
  &quot;devDependencies&quot;: {
    &quot;@babel/cli&quot;: &quot;^7.0.0&quot;,
    &quot;@babel/core&quot;: &quot;^7.0.0&quot;,
    &quot;@babel/plugin-proposal-decorators&quot;: &quot;^7.0.0&quot;,
    &quot;@babel/preset-env&quot;: &quot;^7.0.0&quot;
  },
  &quot;dependencies&quot;: {
    &quot;core-decorators&quot;: &quot;^0.20.0&quot;
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"scripts"</span>: {
    <span class="pl-ent">"start"</span>: <span class="pl-s"><span class="pl-pds">"</span>babel index.js<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"devDependencies"</span>: {
    <span class="pl-ent">"@babel/cli"</span>: <span class="pl-s"><span class="pl-pds">"</span>^7.0.0<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@babel/core"</span>: <span class="pl-s"><span class="pl-pds">"</span>^7.0.0<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@babel/plugin-proposal-decorators"</span>: <span class="pl-s"><span class="pl-pds">"</span>^7.0.0<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@babel/preset-env"</span>: <span class="pl-s"><span class="pl-pds">"</span>^7.0.0<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"dependencies"</span>: {
    <span class="pl-ent">"core-decorators"</span>: <span class="pl-s"><span class="pl-pds">"</span>^0.20.0<span class="pl-pds">"</span></span>
  }
}</pre></div>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="npm install
npm start # babel index.js"><pre class="notranslate">npm install
npm start <span class="pl-c"><span class="pl-c">#</span> babel index.js</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: Tested and confirmed in Node 8/9/10 with npm 5.6.0</li>
<li>OS: OSX 10.12.16</li>
<li>Monorepo: no</li>
<li>How you are using Babel: <code class="notranslate">cli</code> and <code class="notranslate">jest</code></li>
</ul>
<p dir="auto"><strong>Additional context</strong><br>
<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> may be related, however I'm reporting it separately because this error happens with a different type of code and does not have "(This is an error on an internal node. Probably an internal error.)" in the error message.</p>
<p dir="auto">If you make any of the following changes the error goes away:</p>
<ul dir="auto">
<li>Remove the <code class="notranslate">@autobind</code> decorator</li>
<li>Remove the <code class="notranslate">export default</code></li>
<li>Remove the <code class="notranslate">return function() {}</code> so that <code class="notranslate">wrap</code> returns <code class="notranslate">Foo</code> directly.</li>
<li>Remove the <code class="notranslate">node</code> target from <code class="notranslate">env</code> (i.e. change the target so <code class="notranslate">env</code> does not emit a number of transforms)</li>
</ul>