<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <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#c70">Comment # 70</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="bz_obsolete"><a href="attachment.cgi?id=264685&amp;action=diff" name="attach_264685" title="Patch">attachment 264685</a> <a href="attachment.cgi?id=264685&amp;action=edit" title="Patch">[details]</a></span>
Patch

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

I've uploaded  new patch.  Something wrong with mac-debug tests . They are always fails  with different errors.

<span class="quote">&gt;&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:831
&gt;&gt; +        auto addTarget = environment.add(propertyNames().target);
&gt; 
&gt; This should be the private name as well, right?
&gt; 
&gt; It might be good to have tests that this code
&gt; would fail using the public identifier.</span >

I've added tests to check if variable visible in scope

<span class="quote">&gt;&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:837
&gt;&gt; +        auto protoObject = environment.add(propertyNames().underscoreProtoScopeLocalPrivateName);
&gt; 
&gt; Instead of &quot;underscoreProtoScopeLocalPrivateName&quot; we can maybe give this a more descriptive name.
&gt; This is just the current class we're in super class, right?
&gt; like:
&gt; class A extends B { constructor() { let arr = () =&gt; { ... }  }
&gt; this will be &quot;B&quot;, right?
&gt; Maybe we can just name this using some form of &quot;super class&quot;, then?</span >

Renamed to superClassScope

<span class="quote">&gt;&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:3843
&gt;&gt; +        // 'this' can be uninitialized in constructor of derived class so we resolve with underscoreProtoScope variable that stored in arrow function lexical environment in of such cases
&gt; 
&gt; Even though this is uninitialized, don't we always store it in the symbol table?
&gt; So if we read from the scope, we might get jsTDZValue(), but since we're just
&gt; resolving the scope, shouldn't &quot;this&quot; always resolve to the proper scope?</span >

Fixed

<span class="quote">&gt;&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:3892
&gt;&gt; +    emitPutToScope(isDerivedConstructorContext() ? emitResolveScope(nullptr, thisVar) : m_arrowFunctionContextLexicalEnvironmentRegister, thisVar, thisRegister(), DoNotThrowIfNotFound, NotInitialization);
&gt; 
&gt; Why can't we always use &quot;m_arrowFunctionContextLexicalEnvironmentRegister&quot; here?
&gt; We could always call &quot;emitLoadArrowFunctionContextScope()&quot;, too, just to make sure we've resolved to it.</span >

Done.

<span class="quote">&gt;&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:296
&gt;&gt; +        Variable variable(const Identifier&amp;, bool = true);
&gt; 
&gt; I think an &quot;enum class&quot; would be better than bool here, that way all call sites of variable() are more descriptive.
&gt; maybe: &quot;enum class ThisResolutionType { Local, Scoped };&quot;
&gt; or something like that.</span >

Done

<span class="quote">&gt;&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:828
&gt;&gt; +        RefPtr&lt;RegisterID&gt; m_arrowFunctionResolvedLexicalEnvRegister { nullptr };
&gt; 
&gt; I would make &quot;env&quot; to &quot;environment&quot; here, or maybe rename to something shorter like:
&gt; &quot;m_resolvedArrowFunctionScopeContext&quot;</span >

Done

<span class="quote">&gt;&gt; Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp:-1024
&gt;&gt; -                exactRead = ArrowFunctionBoundThisPLoc;
&gt; 
&gt; I think we should remove the definition and other code that looks at &quot;ArrowFunctionBoundThisPLoc&quot; since it's no longer used.</span >

Removed</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>