<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#c4">Comment # 4</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:sbarati@apple.com" title="Saam Barati <sbarati@apple.com>"> <span class="fn">Saam Barati</span></a>
</span></b>
<pre>(In reply to <a href="show_bug.cgi?id=157872#c2">comment #2</a>)
<span class="quote">> Hello guys, It is a RFC.
>
> I created a test case based on the Saam's sample:
>
> class C {
> constructor() { this._x = 45; }
> get foo() { return this._x;}
> }
>
> class D extends C {
>
> x(y = () => super.foo) {
> return y();
> }
> }
>
> if ((new D).x() === 45) {
> print("passed");
> } else {
> print("failed");
> }
>
> I tested it in V8 and SpiderMonkey and they parsed and executed correctly.
> So, I decided to investigate the problem.
>
> I tested the following workaround to find the reason of failing
>
> class D extends C {
>
> x(y) {
> y ||= () => super.foo;
> return y();
> }
> }
>
> And it worked. I noticed that the failing point was the following test
> present in Parser.cpp::parseMemberExpression():
>
> if (!m_lexer->isReparsingFunction()) {
> SuperBinding functionSuperBinding =
> !functionScope->isArrowFunction() &&
> !closestOrdinaryFunctionScope->isEvalContext()
> ? functionScope->expectedSuperBinding()
> : closestOrdinaryFunctionScope->expectedSuperBinding();
> semanticFailIfTrue(functionSuperBinding ==
> SuperBinding::NotNeeded, "super is not valid in this context");
> }
>
> In the first test case, the
> "closestOrdinaryFunctionScope->expectedSuperBinding()" returned
> "SuperBinding::NotNeeded" and in the second case the return was
> "SuperBinding::Needed". I thought it was strange, since the
> "closestOrdinaryFunctionScope" in both cases should be in the same
> configuration. I debugged the parsing phase and noticed that
> "closestOrdinaryFunctionScope->m_expectedSuperBinding" was not being set
> before "parseFunctionParameters" in "Parser<LexerType>::parseFunctionInfo"
> (Parser.cpp).
>
> In my patch proposal, I am setting
> "functionScope->setExpectedSuperBinding(expectedSuperBinding)" before call
> "parseFunctionParameters" in Parser.cpp:2019 as a proof of concept, however,
> I think it should be placed in the first 13 lines of the
> "Parser<LexerType>::parseFunctionInfo" function, since there are others
> "parseFunctionParameters" above the current modification. What do you think?
>
> Also, I would like to know where I should can create a test case for this
> case.</span >
I saw this after I posted my comment, but I believe my above comment answers your questions. The stress test I was speaking about it inside
...Source/JavaScriptCore/tests/stress/... I don't remember the exact file but there is a FIXME with this bug number</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>