<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@gmail.com" title="GSkachkov <gskachkov@gmail.com>"> <span class="fn">GSkachkov</span></a>
</span></b>
<pre>Comment on <span class="bz_obsolete"><a href="attachment.cgi?id=264685&action=diff" name="attach_264685" title="Patch">attachment 264685</a> <a href="attachment.cgi?id=264685&action=edit" title="Patch">[details]</a></span>
Patch
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=264685&action=review">https://bugs.webkit.org/attachment.cgi?id=264685&action=review</a>
I've uploaded new patch. Something wrong with mac-debug tests . They are always fails with different errors.
<span class="quote">>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:831
>> + auto addTarget = environment.add(propertyNames().target);
>
> This should be the private name as well, right?
>
> It might be good to have tests that this code
> would fail using the public identifier.</span >
I've added tests to check if variable visible in scope
<span class="quote">>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:837
>> + auto protoObject = environment.add(propertyNames().underscoreProtoScopeLocalPrivateName);
>
> Instead of "underscoreProtoScopeLocalPrivateName" we can maybe give this a more descriptive name.
> This is just the current class we're in super class, right?
> like:
> class A extends B { constructor() { let arr = () => { ... } }
> this will be "B", right?
> Maybe we can just name this using some form of "super class", then?</span >
Renamed to superClassScope
<span class="quote">>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:3843
>> + // '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
>
> Even though this is uninitialized, don't we always store it in the symbol table?
> So if we read from the scope, we might get jsTDZValue(), but since we're just
> resolving the scope, shouldn't "this" always resolve to the proper scope?</span >
Fixed
<span class="quote">>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:3892
>> + emitPutToScope(isDerivedConstructorContext() ? emitResolveScope(nullptr, thisVar) : m_arrowFunctionContextLexicalEnvironmentRegister, thisVar, thisRegister(), DoNotThrowIfNotFound, NotInitialization);
>
> Why can't we always use "m_arrowFunctionContextLexicalEnvironmentRegister" here?
> We could always call "emitLoadArrowFunctionContextScope()", too, just to make sure we've resolved to it.</span >
Done.
<span class="quote">>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:296
>> + Variable variable(const Identifier&, bool = true);
>
> I think an "enum class" would be better than bool here, that way all call sites of variable() are more descriptive.
> maybe: "enum class ThisResolutionType { Local, Scoped };"
> or something like that.</span >
Done
<span class="quote">>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:828
>> + RefPtr<RegisterID> m_arrowFunctionResolvedLexicalEnvRegister { nullptr };
>
> I would make "env" to "environment" here, or maybe rename to something shorter like:
> "m_resolvedArrowFunctionScopeContext"</span >
Done
<span class="quote">>> Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp:-1024
>> - exactRead = ArrowFunctionBoundThisPLoc;
>
> I think we should remove the definition and other code that looks at "ArrowFunctionBoundThisPLoc" 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>