<p dir="auto">If I understand things correctly, under ES6, the second line should raise a referenceError due to x not yet having been declared.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;
let b = x; // should throw a referenceError
console.log('b: ', b);
b = 2;
const x = 'a';"><pre class="notranslate"><code class="notranslate">"use strict";
let b = x; // should throw a referenceError
console.log('b: ', b);
b = 2;
const x = 'a';
</code></pre></div>
<p dir="auto">Running this through Babel, I get no referenceError. But the following code does raise a referenceError:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;
let b = x; // throws a referenceError
console.log('b: ', b);
b = 2;"><pre class="notranslate"><code class="notranslate">"use strict";
let b = x; // throws a referenceError
console.log('b: ', b);
b = 2;
</code></pre></div>
<p dir="auto">Another one from the defs test suite:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="~/projects/defs.js/tests % cat used-in-same-declaration.js
&quot;use strict&quot;;
let x = x; // error
let y = 1, z = y; // ok
let a = b, b = 1; // error"><pre class="notranslate"><span class="pl-c1">~</span><span class="pl-pds"><span class="pl-c1">/</span>projects<span class="pl-c1">/</span>defs</span><span class="pl-kos">.</span><span class="pl-c1">js</span><span class="pl-c1">/</span><span class="pl-s1">tests</span> <span class="pl-c1">%</span> <span class="pl-s1">cat</span> <span class="pl-s1">used</span><span class="pl-c1">-</span><span class="pl-s1">in</span><span class="pl-c1">-</span><span class="pl-s1">same</span><span class="pl-c1">-</span><span class="pl-s1">declaration</span><span class="pl-kos">.</span><span class="pl-c1">js</span>
<span class="pl-s">"use strict"</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span><span class="pl-kos">;</span> <span class="pl-c">// error</span>
<span class="pl-k">let</span> <span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-s1">z</span> <span class="pl-c1">=</span> <span class="pl-s1">y</span><span class="pl-kos">;</span> <span class="pl-c">// ok</span>
<span class="pl-k">let</span> <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">b</span><span class="pl-kos">,</span> <span class="pl-s1">b</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span><span class="pl-kos">;</span> <span class="pl-c">// error</span></pre></div>
<p dir="auto">Babel doesn't complain about this currently but should error something similar to</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="line 2: x is referenced before its declaration
line 4: b is referenced before its declaration"><pre class="notranslate"><code class="notranslate">line 2: x is referenced before its declaration
line 4: b is referenced before its declaration
</code></pre></div>
<p dir="auto">To clarify, I'm asking for static errors.</p>