<p dir="auto">There is a bug on the <code class="notranslate">class</code> transform, which does not match spec 1:1. When a constructor is not defined, the parent constructor should be called with <code class="notranslate">...args</code>, which means calling <code class="notranslate">Array.prototype[Symbol.iterator]</code> under the hood.</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="Array.prototype[Symbol.iterator] = () =&gt; console.log('potato');
class Foo extends Error() {}
new Foo();"><pre class="notranslate"><span class="pl-v">Array</span><span class="pl-kos">.</span><span class="pl-c1">prototype</span><span class="pl-kos">[</span><span class="pl-v">Symbol</span><span class="pl-kos">.</span><span class="pl-c1">iterator</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-kos">(</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-s">'potato'</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-k">extends</span> <span class="pl-v">Error</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">new</span> <span class="pl-v">Foo</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>

<p dir="auto">Tried with REPL, es2015 preset.</p>
<h3 dir="auto">Expected Behavior</h3>


<p dir="auto"><code class="notranslate">potato</code> should appear in the console.</p>
<h3 dir="auto">Current Behavior</h3>
<p dir="auto"><code class="notranslate">potato</code> does not appear in the console :( Essentially because no <code class="notranslate">Symbol.iterator</code> is pulled in.</p>
<h3 dir="auto">Possible Solution</h3>
<p dir="auto">Transform:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="(Foo.__proto__ || Object.getPrototypeOf(Foo)).apply(this, arguments)"><pre class="notranslate"><span class="pl-kos">(</span><span class="pl-v">Foo</span><span class="pl-kos">.</span><span class="pl-c1">__proto__</span> <span class="pl-c1">||</span> <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">getPrototypeOf</span><span class="pl-kos">(</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-en">apply</span><span class="pl-kos">(</span><span class="pl-smi">this</span><span class="pl-kos">,</span> <span class="pl-smi">arguments</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">Into:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="(Foo.__proto__ || Object.getPrototypeOf(Foo))(...args)"><pre class="notranslate"><span class="pl-kos">(</span><span class="pl-v">Foo</span><span class="pl-kos">.</span><span class="pl-c1">__proto__</span> <span class="pl-c1">||</span> <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">getPrototypeOf</span><span class="pl-kos">(</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-s1">args</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">And let the spread/rest be recompiled to use the iterator.</p>
<h3 dir="auto">Context</h3>
<p dir="auto">See <a href="https://bugs.chromium.org/p/v8/issues/detail?id=7710&amp;can=2&amp;start=0&amp;num=100&amp;q=&amp;colspec=ID%20Type%20Status%20Priority%20Owner%20Summary%20HW%20OS%20Component%20Stars&amp;groupby=&amp;sort=" rel="nofollow">an V8 issue</a> for that. It's probably a very edge case anyway, but having the strict class transformer and the loose one, I'd expect the strict to be strict, not semi-loose :)</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="Array.prototype[Symbol.iterator] = function() {
  throw new Error();
}
class c {} ;
class b extends c {}
new b();"><pre class="notranslate"><span class="pl-v">Array</span><span class="pl-kos">.</span><span class="pl-c1">prototype</span><span class="pl-kos">[</span><span class="pl-v">Symbol</span><span class="pl-kos">.</span><span class="pl-c1">iterator</span><span class="pl-kos">]</span> <span class="pl-c1">=</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">throw</span> <span class="pl-k">new</span> <span class="pl-v">Error</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">class</span> <span class="pl-s1">c</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-s1">b</span> <span class="pl-k">extends</span> <span class="pl-s1">c</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
<span class="pl-k">new</span> <span class="pl-s1">b</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<h3 dir="auto">Babel Configuration (.babelrc, package.json, cli command)</h3>

<p dir="auto">presets -latest</p>
<h3 dir="auto">Expected Behavior</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="→ cat test2.js
Array.prototype[Symbol.iterator] = function() {
  throw new Error();
}
class c {} ;
class b extends c {}
var y = new b();

→ ./out.gn/x64.debug/d8 test2.js
test2.js:2: Error
  throw new Error();
  ^
Error
    at Array.(anonymous function) (test2.js:2:9)
    at b (test2.js:5:1)
    at test2.js:6:9"><pre class="notranslate"><code class="notranslate">→ cat test2.js
Array.prototype[Symbol.iterator] = function() {
  throw new Error();
}
class c {} ;
class b extends c {}
var y = new b();

→ ./out.gn/x64.debug/d8 test2.js
test2.js:2: Error
  throw new Error();
  ^
Error
    at Array.(anonymous function) (test2.js:2:9)
    at b (test2.js:5:1)
    at test2.js:6:9
</code></pre></div>
<h3 dir="auto">Current Behavior</h3>
<p dir="auto">No error</p>


<h3 dir="auto">Possible Solution</h3>


<h3 dir="auto">Context</h3>


<h3 dir="auto">Your Environment</h3>

<table role="table">
<thead>
<tr>
<th>software</th>
<th>version</th>
</tr>
</thead>
<tbody>
<tr>
<td>Babel</td>
<td></td>
</tr>
<tr>
<td>node</td>
<td></td>
</tr>
<tr>
<td>npm</td>
<td></td>
</tr>
<tr>
<td>Operating System</td>
<td></td>
</tr>
</tbody>
</table>