<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&#64;apple.com" title="Saam Barati &lt;sbarati&#64;apple.com&gt;"> <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">&gt; Hello guys, It is a RFC.
&gt; 
&gt; I created a test case based on the Saam's sample:
&gt; 
&gt; class C {
&gt;   constructor() { this._x = 45; }
&gt;   get foo() { return this._x;}
&gt; }
&gt; 
&gt; class D extends C {
&gt; 
&gt;   x(y = () =&gt; super.foo) {
&gt;     return y();
&gt;   }
&gt; }
&gt; 
&gt; if ((new D).x() === 45) {
&gt;   print(&quot;passed&quot;);
&gt; } else {
&gt;   print(&quot;failed&quot;);
&gt; }
&gt; 
&gt; I tested it in V8 and SpiderMonkey and they parsed and executed correctly.
&gt; So, I decided to investigate the problem.
&gt; 
&gt; I tested the following workaround to find the reason of failing
&gt; 
&gt; class D extends C {
&gt; 
&gt;   x(y) {
&gt;     y ||= () =&gt; super.foo;
&gt;     return y();
&gt;   }
&gt; }
&gt; 
&gt; And it worked. I noticed that the failing point was the following test
&gt; present in Parser.cpp::parseMemberExpression():
&gt; 
&gt; if (!m_lexer-&gt;isReparsingFunction()) {
&gt;                 SuperBinding functionSuperBinding =
&gt; !functionScope-&gt;isArrowFunction() &amp;&amp;
&gt; !closestOrdinaryFunctionScope-&gt;isEvalContext()
&gt;                     ? functionScope-&gt;expectedSuperBinding()
&gt;                     : closestOrdinaryFunctionScope-&gt;expectedSuperBinding();
&gt;                 semanticFailIfTrue(functionSuperBinding ==
&gt; SuperBinding::NotNeeded, &quot;super is not valid in this context&quot;);
&gt;             }
&gt; 
&gt; In the first test case, the
&gt; &quot;closestOrdinaryFunctionScope-&gt;expectedSuperBinding()&quot; returned
&gt; &quot;SuperBinding::NotNeeded&quot; and in the second case the return was
&gt; &quot;SuperBinding::Needed&quot;. I thought it was strange, since the
&gt; &quot;closestOrdinaryFunctionScope&quot; in both cases should be in the same
&gt; configuration. I debugged the parsing phase and noticed that
&gt; &quot;closestOrdinaryFunctionScope-&gt;m_expectedSuperBinding&quot; was not being set
&gt; before &quot;parseFunctionParameters&quot; in &quot;Parser&lt;LexerType&gt;::parseFunctionInfo&quot;
&gt; (Parser.cpp).
&gt; 
&gt; In my patch proposal, I am setting
&gt; &quot;functionScope-&gt;setExpectedSuperBinding(expectedSuperBinding)&quot; before call
&gt; &quot;parseFunctionParameters&quot; in Parser.cpp:2019 as a proof of concept, however,
&gt; I think it should be placed in the first 13 lines of the
&gt; &quot;Parser&lt;LexerType&gt;::parseFunctionInfo&quot; function, since there are others
&gt; &quot;parseFunctionParameters&quot; above the current modification. What do you think?
&gt; 
&gt; Also, I would like to know where I should can create a test case for this
&gt; 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>