<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><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> changed
<a class="bz_bug_link
bz_status_NEW "
title="NEW - [ES6] Arrow function syntax. Arrow function should support the destructuring parameters."
href="https://bugs.webkit.org/show_bug.cgi?id=146934">bug 146934</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Attachment #268861 Flags</td>
<td>review?
</td>
<td>review-
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - [ES6] Arrow function syntax. Arrow function should support the destructuring parameters."
href="https://bugs.webkit.org/show_bug.cgi?id=146934#c6">Comment # 6</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - [ES6] Arrow function syntax. Arrow function should support the destructuring parameters."
href="https://bugs.webkit.org/show_bug.cgi?id=146934">bug 146934</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>Comment on <span class=""><a href="attachment.cgi?id=268861&action=diff" name="attach_268861" title="Patch">attachment 268861</a> <a href="attachment.cgi?id=268861&action=edit" title="Patch">[details]</a></span>
Patch
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=268861&action=review">https://bugs.webkit.org/attachment.cgi?id=268861&action=review</a>
this seems like the right approach, just a few comments to clean up the code.
<span class="quote">> Source/JavaScriptCore/parser/Parser.h:1047
> + ALWAYS_INLINE bool isArrowFunctionNoOrOneParamter()
> {
> bool isArrowFunction = false;
>
> - if (match(EOFTOK))
> + if (match(EOFTOK) || (!match(IDENT) && !match(OPENPAREN)))
> return isArrowFunction;
>
> SavePoint saveArrowFunctionPoint = createSavePoint();
> + if (match(IDENT))
> + isArrowFunction = consume(IDENT) && match(ARROWFUNCTION);
> + else if (consume(OPENPAREN) && consume(CLOSEPAREN))
> + isArrowFunction = match(ARROWFUNCTION);
>
> - if (consume(OPENPAREN)) {
> - bool isArrowFunctionParamters = true;
> + restoreSavePoint(saveArrowFunctionPoint);
> +
> + return isArrowFunction;
> + }</span >
This function has some redundancy with the below function, lets just combine
the necessary bits into the below function.
<span class="quote">> Source/JavaScriptCore/parser/Parser.h:1049
> + template <class TreeBuilder> bool isArrowFunctionParamters(TreeBuilder& context)</span >
We don't need to templatize this once we move it to SyntaxChecker (see below).
Also, this function has been misspelled, lets fix the spelling in this patch:
"isArrowFunctionParamters" => "isArrowFunctionParameters"
<span class="quote">> Source/JavaScriptCore/parser/Parser.h:1057
> + if (isArrowFunctionNoOrOneParamter())
> + isArrowFunction = true;</span >
Instead of calling the above function, you
can just check:
```
if (match(IDENT)) {
save point create;
next();
check if arrow function
save point restore;
} else if ....
```
<span class="quote">> Source/JavaScriptCore/parser/Parser.h:1066
> + unsigned parametersCount = 1;</span >
start this at zero.
Even though we ignore this number, it should start at zero.
<span class="quote">> Source/JavaScriptCore/parser/Parser.h:1067
> + isArrowFunction = parseFormalParameters(context, context.createFormalParameterList(), parametersCount) && consume(CLOSEPAREN) && match(ARROWFUNCTION);</span >
Instead of passing in "context" here, we should create a SyntaxChecker and pass that in.
That way we're not actually allocating AST nodes that we throw away.
<span class="quote">> LayoutTests/js/script-tests/arrowfunction-syntax.js:79
> </span >
add a test or a few tests for rest parameters:
```
(...rest) => rest;
```
etc.</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>