<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:gskachkov@gmail.com" title="GSkachkov <gskachkov@gmail.com>"> <span class="fn">GSkachkov</span></a>
</span> changed
<a class="bz_bug_link
bz_status_NEW "
title="NEW - [ES6] Arrow function syntax. Arrow function specific features. Lexical bind "super" property"
href="https://bugs.webkit.org/show_bug.cgi?id=149615">bug 149615</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 #267799 is obsolete</td>
<td>1
</td>
<td>
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - [ES6] Arrow function syntax. Arrow function specific features. Lexical bind "super" property"
href="https://bugs.webkit.org/show_bug.cgi?id=149615#c15">Comment # 15</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - [ES6] Arrow function syntax. Arrow function specific features. Lexical bind "super" property"
href="https://bugs.webkit.org/show_bug.cgi?id=149615">bug 149615</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=""><a href="attachment.cgi?id=267799&action=diff" name="attach_267799" title="Patch">attachment 267799</a> <a href="attachment.cgi?id=267799&action=edit" title="Patch">[details]</a></span>
Patch
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=267799&action=review">https://bugs.webkit.org/attachment.cgi?id=267799&action=review</a>
<span class="quote">>> Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp:69
>> + // this executable is part of the class
>
> comment isn't needed</span >
Removed
<span class="quote">>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:575
>> + if (SourceParseMode::ArrowFunctionMode == parseMode && (functionNode->usesThis() || isDerivedClassContext() || isDerivedConstructorContext()))
>
> Why are these new conditions needed?
> Why do we need to load this if we're "SourceParseMode::ArrowFunctionMode == parseMode && (isDerivedClassContext() || isDerivedConstructorContext())"?</span >
Without this condition following code will raise ReferenceError 'this' is undefined so to fix this error I've added this condition.
var A = class A {
constructor() {
this.value = 'testValue';
}
getValue () {
return this.value;
}
};
var B = class B extends A {
getParentValue() {
var arrow = () => super.getValue();
return arrow();
}
};
var b = new B();
b. getParentValue()
<span class="quote">>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:4050
>> + if ((isConstructor() && constructorKind() == ConstructorKind::Derived) || (m_codeBlock->isClassContext())) {
>
> style: the parens around "m_codeBlock->isClassContext()" aren't needed.</span >
Done
<span class="quote">>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:813
>> + }
>
> Nit: I think this whole section of code would be easier to read like this:
> ```
> if (constructorKind() == ConstructorKind::Derived || isDerivedConstructorContext())
> newDerivedContextType = DerivedContextType::DerivedConstructorContext;
> else if (m_codeBlock->isClassContext() || (m_codeBlock->isArrowFunction() && m_derivedContextType == DerivedContextType::DerivedMethodContext))
> newDerivedContextType = DerivedContextType::DerivedMethodContext
> ```
>
> Also, why do we need to check "m_codeBlock->isArrowFunction()" when checking "m_derivedContextType == DerivedContextType::DerivedMethodContext"?
> When would we have "!m_codeBlock->isArrowFunction() && m_derivedContextType == DerivedContextType::DerivedMethodContext"?</span >
Ohh, I see. We don't need to check m_codeBlock->isArrowFunction() because it already true because of this condition metadata->parseMode() == SourceParseMode::ArrowFunctionMode.
<span class="quote">>> Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:182
>> + RegisterID* scope = generator.emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment();
>
> This isn't a JSScope. Maybe a better variable name is "derivedConstructor" or something similar.</span >
Renamed
<span class="quote">>> Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp:195
>> + EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock.isStrictMode(), thisTDZMode, codeBlock.unlinkedCodeBlock()->derivedContextType(), codeBlock.unlinkedCodeBlock()->isArrowFunction(), &variablesUnderTDZ);
>
> have you tried this out inside the inspector to make sure it works?
> I.e, pausing inside an arrow function and typing in "super" into the console?</span >
Good question. I vent done this. I've checked and it does not work. When I typing 'super' into console it raise exception 'SyntaxError: super is only valid inside functions.' The same behavior inside of the method of class and inside of the arrow function in class method. Looks like bug in class implementation.
<span class="quote">>> Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-superproperty.js:160
>> + erorr = true;
>
> typo: "erorr" => "error"</span >
Fixed
<span class="quote">>> LayoutTests/js/script-tests/arrowfunction-superproperty.js:78
>> +// FIXME: Problem with access to the super before super in constructor
>
> nit: "super before super" => "super before super()"</span >
Done</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>