<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Our parser doesn't properly parse default parameter expressions in a class method"
href="https://bugs.webkit.org/show_bug.cgi?id=157872#c19">Comment # 19</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Our parser doesn't properly parse default parameter expressions in a class method"
href="https://bugs.webkit.org/show_bug.cgi?id=157872">bug 157872</a>
from <span class="vcard"><a class="email" href="mailto:ticaiolima@gmail.com" title="Caio Lima <ticaiolima@gmail.com>"> <span class="fn">Caio Lima</span></a>
</span></b>
<pre>(In reply to <a href="show_bug.cgi?id=157872#c18">comment #18</a>)
<span class="quote">> Comment on <span class=""><a href="attachment.cgi?id=280110&action=diff" name="attach_280110" title="Patch">attachment 280110</a> <a href="attachment.cgi?id=280110&action=edit" title="Patch">[details]</a></span>
> Patch
>
> View in context:
> <a href="https://bugs.webkit.org/attachment.cgi?id=280110&action=review">https://bugs.webkit.org/attachment.cgi?id=280110&action=review</a>
>
> r=me wth comments
>
> > Source/JavaScriptCore/parser/Parser.cpp:1929
> > + functionScope->setExpectedSuperBinding(expectedSuperBinding);
>
> Can you remove the duplicate call below to setExpectedSuperKind(...)?</span >
Sure. Actually I can just remove the call on line :1951 (inside loadCachedFunction), since the "expectedSuperBinding" can change "if (m_defaultConstructorKind != ConstructorKind::None)".
<span class="quote">> Also, I wonder if we should be calling setConstructKind up here too. I need
> to think about it more.</span >
Actually, I think so. I tested the following sample and got SyntaxError:
class C {
constructor() {
this._x = 45;
}
get foo() {
return this._x;
}
}
class D extends C {
constructor(x = () => super()) {
x();
}
x() {
return super.foo;
}
}
if ((new D).x() === 45) {
print("passed");
} else {
print("failed");
}
The result in v8 and Spider monkey was correct. I set it in the beginning of function and things worked properly.
<span class="quote">> > Source/JavaScriptCore/tests/stress/arrow-functions-as-default-parameter-values.js:162
> > + class D extends C {
> > + x(y = (y = () => super.foo) => {return y()}) {
> > + return y();
> > + }
> > + }
>
> Can you also add a test where we use super inside an arrow function inside a
> derived constructor's default parameter expression?</span >
<span class="quote">> > LayoutTests/js/script-tests/parser-syntax-check.js:746
> > +valid("class C { constructor() { this._x = 45; } get foo() { return this._x;} } class D extends C { x(y = (y = () => super.foo) => {return y()}) { return y(); } }")
>
> Ditto for a constructor's syntax here</span >
No problem.</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>