[Webkit-unassigned] [Bug 157872] Our parser doesn't properly parse default parameter expressions in a class method

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun May 29 23:10:32 PDT 2016


https://bugs.webkit.org/show_bug.cgi?id=157872

--- Comment #4 from Saam Barati <sbarati at apple.com> ---
(In reply to comment #2)
> 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.
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

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160530/a256c7e0/attachment.html>


More information about the webkit-unassigned mailing list