<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 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>
</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@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=264078&action=diff" name="attach_264078" title="Patch">attachment 264078</a> <a href="attachment.cgi?id=264078&action=edit" title="Patch">[details]</a></span>
Patch
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=264078&action=review">https://bugs.webkit.org/attachment.cgi?id=264078&action=review</a>
<span class="quote">>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:849
>> + m_arrowFunctionContextLexicalEnvironmentRegister = emitMove(newBlockScopeVariable(), m_scopeRegister);
>
> I was wrong about advising you on this earlier.
> I forgot that pushLexicalScopeInternal already creates a variable for us.
> Because you have captured variables, we will create a block scoped variable for
> the scope.
> So all you have to do is this:
> m_arrowFunctionContextLexcialEnvironmentRegister = m_symbolTableStack.last().m_scope.
> 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">>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2989
>> + if (m_codeType == FunctionCode) {
>
> I realized we don't need this.
> We should only need to do this once per function.
> If you look how new_target is materialized now, it happens
> before we create a "this". So I think it'd be wrong to update
> 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">>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:3881
>> +{
>
> There are a few interesting things to consider here that seem like they are problems.
> 1) consider the problem of using the literal string "__proto__":
> class A extends B {
> let arr1 = () => {
> let __proto__ = "blah";
> let arr2 = () => super();
> arr2();
> }
> }
> This strategy worked with "this" because no variable can be named "this". But variables can be named "__proto__"
>
> 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).
> class A extends B {
> let arr1 = () => { ... }
> A.__proto__ = null;
> arr1();
> }
> I wonder what happens just in normal classes with this.
>
> 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.
> It's worth considering this problem.
>
> 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 = () => {
var nestedArrow = () => {
super();
}
nestedArrow();
};
arrowInChildConstructor();
}
};
Stack trace is:
<a href="mailto:ParentClass@test_class_14.js">ParentClass@test_class_14.js</a>:9:22
<a href="mailto:nestedArrow@test_class_14.js">nestedArrow@test_class_14.js</a>:20:14
<a href="mailto:arrowInChildConstructor@test_class_14.js">arrowInChildConstructor@test_class_14.js</a>:23:18
<a href="mailto:ChildClass@test_class_14.js">ChildClass@test_class_14.js</a>:26:28
global <a href="mailto:code@test_class_14.js">code@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>