<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:gskachkov&#64;gmail.com" title="GSkachkov &lt;gskachkov&#64;gmail.com&gt;"> <span class="fn">GSkachkov</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ES6] Arrow function created before super() causes TDZ, should it?"
   href="https://bugs.webkit.org/show_bug.cgi?id=149338">bug 149338</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #264078 is obsolete</td>
           <td>1
           </td>
           <td>
               &nbsp;
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ES6] Arrow function created before super() causes TDZ, should it?"
   href="https://bugs.webkit.org/show_bug.cgi?id=149338#c53">Comment # 53</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ES6] Arrow function created before super() causes TDZ, should it?"
   href="https://bugs.webkit.org/show_bug.cgi?id=149338">bug 149338</a>
              from <span class="vcard"><a class="email" href="mailto:gskachkov&#64;gmail.com" title="GSkachkov &lt;gskachkov&#64;gmail.com&gt;"> <span class="fn">GSkachkov</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=264078&amp;action=diff" name="attach_264078" title="Patch">attachment 264078</a> <a href="attachment.cgi?id=264078&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=264078&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=264078&amp;action=review</a>

<span class="quote">&gt;&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:849
&gt;&gt; +    m_arrowFunctionContextLexicalEnvironmentRegister = emitMove(newBlockScopeVariable(), m_scopeRegister);
&gt; 
&gt; I was wrong about advising you on this earlier.
&gt; I forgot that pushLexicalScopeInternal already creates a variable for us.
&gt; Because you have captured variables, we will create a block scoped variable for
&gt; the scope. 
&gt; So all you have to do is this:
&gt; m_arrowFunctionContextLexcialEnvironmentRegister = m_symbolTableStack.last().m_scope.
&gt; Feel free to add asserts around the pushLexicalScopeInternal call to make sure it actually adds exactly one item to the symbol table stack.</span >

Done

<span class="quote">&gt;&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2989
&gt;&gt; +        if (m_codeType == FunctionCode)  {
&gt; 
&gt; I realized we don't need this.
&gt; We should only need to do this once per function.
&gt; If you look how new_target is materialized now, it happens
&gt; before we create a &quot;this&quot;. So I think it'd be wrong to update
&gt; this value over time. It should just happen once at the very beginning of the program.</span >

I've split this into two methods

<span class="quote">&gt;&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:3881
&gt;&gt; +{
&gt; 
&gt; There are a few interesting things to consider here that seem like they are problems.
&gt; 1) consider the problem of using the literal string &quot;__proto__&quot;:
&gt; class A extends B {
&gt;     let arr1 = () =&gt; {
&gt;         let __proto__ = &quot;blah&quot;;
&gt;         let arr2 = () =&gt; super();
&gt;         arr2();
&gt;     }
&gt; }
&gt; This strategy worked with &quot;this&quot; because no variable can be named &quot;this&quot;. But variables can be named &quot;__proto__&quot;
&gt; 
&gt; 2) what happens when __proto__ is overwritten (I'm not really sure if this is a problem or what's supposed to happen with respect to the specification, but it's probably worth looking into).
&gt; class A extends B {
&gt;     let arr1 = () =&gt; { ... }
&gt;     A.__proto__ = null;
&gt;     arr1();
&gt; }
&gt; I wonder what happens just in normal classes with this.
&gt; 
&gt; 3) If we're storing values in m_calleeRegister, maybe we're doing this wrong. I think this might break stack traces because it will look like an arrow functions parent frame is displayed twice on a stack trace if an error is thrown.
&gt; It's worth considering this problem.
&gt; 
&gt; For all problems above, if they really are problems, we should have tests for them, too.</span >

Added additional tests to arrowfunction-lexical-bind-supercall-2.js module for cases that you mention.
Stack trace looks correct
for instance for following code:
var errorStack;

var ParentClass = class ParentClass {
  constructor() {
    try {
      this.idValue = 'testValue';
      throw new Error('Error');
    } catch (e) {
      errorStack  = e.stack;
    }
  }
};

var ChildClass = class ChildClass extends ParentClass {
  constructor () {
    var arrowInChildConstructor = () =&gt; {
      var nestedArrow = () =&gt; {
        super();
      }
      nestedArrow();
    };
    arrowInChildConstructor();
  }
};


Stack trace is:
<a href="mailto:ParentClass&#64;test_class_14.js">ParentClass&#64;test_class_14.js</a>:9:22
<a href="mailto:nestedArrow&#64;test_class_14.js">nestedArrow&#64;test_class_14.js</a>:20:14
<a href="mailto:arrowInChildConstructor&#64;test_class_14.js">arrowInChildConstructor&#64;test_class_14.js</a>:23:18
<a href="mailto:ChildClass&#64;test_class_14.js">ChildClass&#64;test_class_14.js</a>:26:28
global <a href="mailto:code&#64;test_class_14.js">code&#64;test_class_14.js</a>:31:25</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>