[Webkit-unassigned] [Bug 146934] [ES6] Arrow function syntax. Arrow function should support the destructuring parameters.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Jan 10 16:59:16 PST 2016


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

Saam Barati <sbarati at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #268657|review?, commit-queue?      |review-, commit-queue-
              Flags|                            |

--- Comment #2 from Saam Barati <sbarati at apple.com> ---
Comment on attachment 268657
  --> https://bugs.webkit.org/attachment.cgi?id=268657
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=268657&action=review

> Source/JavaScriptCore/parser/Parser.h:1080
> +        else if (match(OPENPAREN)) {
> +            // Let's check if this destructuring paramters
> +            SavePoint saveArrowFunctionPoint = createSavePoint();
> +            next(); // Consume OPENPAREN;
> +            auto pattern = tryParseDestructuringPatternExpression(context, AssignmentContext::DeclarationStatement);
> +            isArrowFunction = pattern && consume(CLOSEPAREN) && match(ARROWFUNCTION);
> +            
> +            restoreSavePoint(saveArrowFunctionPoint);
> +        }
> +        

This code isn't correct.
It won't parse:
```
(a, b, {c}, [d], {e, f}) => ...;
```

I suggest an alternate approach here:
have this code check if we have the single parameter name with no parens case:
```
let x = a=>a;
``` 
and otherwise, we already know how to parse "(p1, p2, ...)" style parameter lists
in another function in the parser. We should use that same code here. Either we use
it directly as is (probably not possible), or we should abstract that code in such a way
that this code can use it. That way, we don't have to places in the parser where we parse parameters.

The reason we have this problem in the first place is that we have two places where we parse
parameters, lets not make that mistake again.

-- 
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/20160111/5cb4dadd/attachment.html>


More information about the webkit-unassigned mailing list