<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function"
   href="https://bugs.webkit.org/show_bug.cgi?id=144955#c58">Comment # 58</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function"
   href="https://bugs.webkit.org/show_bug.cgi?id=144955">bug 144955</a>
              from <span class="vcard"><a class="email" href="mailto:gskachkov&#64;gmail.com" title="GSkachkov &lt;gskachkov&#64;gmail.com&gt;"> <span class="fn">GSkachkov</span></a>
</span></b>
        <pre>Comment on <span class="bz_obsolete"><a href="attachment.cgi?id=254445&amp;action=diff" name="attach_254445" title="Patch">attachment 254445</a> <a href="attachment.cgi?id=254445&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=254445&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=254445&amp;action=review</a>

<span class="quote">&gt;&gt; Source/JavaScriptCore/parser/Parser.cpp:607
&gt;&gt; +    bool correctArrowFinish = isEndOfArrowFunction() || match(EOFTOK);
&gt; 
&gt; `match(EOFTOK)` is contained in `isEndOfArrowFunction()`. So I think `match(EOFTOK)` is not needed. Correct?
&gt; If so, we can change it to `failIfFalse(isEndOfArrowFunction(), &quot;...&quot;);` by merging the following check.</span >

Done

<span class="quote">&gt;&gt; Source/JavaScriptCore/parser/Parser.cpp:608
&gt;&gt; +    failIfFalse(correctArrowFinish, &quot;Expected a ';', ']', '}', ')', or ',' following a arrow function statement&quot;);
&gt; 
&gt; it seems refering to EOF and Line terminator is needed.</span >

Done

<span class="quote">&gt;&gt; Source/JavaScriptCore/parser/Parser.cpp:1257
&gt;&gt; +        result = parseArrowFunctionStatement(context, parseType);
&gt; 
&gt; This `parseArrowFunctionStatement` name confuses me.
&gt; This function is used when
&gt; 
&gt; (e) `=&gt; expr;`
&gt; 
&gt; part, right? If so, I think clearer name is encouraged.</span >

I've renamed it to parseArrowFunctionExpression.

<span class="quote">&gt;&gt; Source/JavaScriptCore/parser/Parser.cpp:1407
&gt;&gt; +template &lt;typename LexerType&gt; template &lt;class TreeBuilder&gt; int Parser&lt;LexerType&gt;::parseArrowFunctionParameters(TreeBuilder&amp; context, FunctionParseMode mode, ParserFunctionInfo&lt;TreeBuilder&gt;&amp; info)
&gt; 
&gt; Why parseArrowFunctionParameters is needed in addition to `parseFunctionParameters`?
&gt; Is it possible just using `parseFunctionParameters`?</span >

Yep, I've refactored, please take a look if it looks better.

<span class="quote">&gt;&gt; Source/JavaScriptCore/parser/Parser.cpp:1585
&gt;&gt; +        position.offset++;
&gt; 
&gt; Is it handled when &lt;CR&gt;&lt;LF&gt; comes? Hm, this part looks a little bit weird.</span >

It set position to &lt;CR&gt;, because there are no TOCKEN NextLine. So we back to last before new line and add move one position forward

<span class="quote">&gt;&gt; Source/JavaScriptCore/parser/Parser.cpp:1621
&gt;&gt; +        failIfFalse(isEndOfArrowFunction(), &quot;Expected the closing ';' ',' ']' ')' '}' after arrow function&quot;);
&gt; 
&gt; it seems refering to EOF and Line terminator is needed.</span >

Done

<span class="quote">&gt;&gt; Source/JavaScriptCore/parser/Parser.h:632
&gt;&gt; +        
&gt; 
&gt; Is the above match(EOFTOK) check needed?</span >

Yes. 
It solve case when you at EOF and uses save point. If you do restoreSavePoint(saveArrowFunctionPoint) it will back to one step before EOF

<span class="quote">&gt;&gt; Source/JavaScriptCore/parser/SourceCode.h:130
&gt;&gt; +            UChar symbol = provider()-&gt;source()[endArrowFunction - 1];
&gt; 
&gt; I suggest adding `ASSERT(endArrowFunction &gt;= 1);` if it's guaranteed.</span >

Done

<span class="quote">&gt;&gt; Source/JavaScriptCore/parser/SourceCode.h:131
&gt;&gt; +            ASSERT_UNUSED(symbol, symbol == 13 || symbol == 10 || symbol == ',' || symbol == ';' || symbol == ')' || symbol == ']' || symbol == '}');
&gt; 
&gt; What are 13 and 10? Is it possible to use Lexer&lt;...&gt;::isLineTerminator? So are 0x2028/0x2029 is handled? (They are also line terminators.)</span >

I've added new function isLineTerminator. I'm not sure that it will be good idea to add new dependany to this module. As for me Lexer is from another layer, and SourceCode should not interact with it. What do you think?

<span class="quote">&gt;&gt; Source/JavaScriptCore/parser/SourceProviderCacheItem.h:73
&gt;&gt;          token.m_location.endOffset = closeBraceOffset + 1;
&gt; 
&gt; Is this `+1` OK for non `CLOSEBRACE` token? For example, If the arrow function expression is splitted by previous line terminators, I think (almost) arbitrary tokens can come here. Correct?</span >

Thanks for hint, I missed that case. I've added new property in parameters to store if line terminator was before token</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>