Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6: Spread Element (for function argument) #1169

Closed
1 task
markelog opened this issue Apr 29, 2015 · 7 comments
Closed
1 task

ES6: Spread Element (for function argument) #1169

markelog opened this issue Apr 29, 2015 · 7 comments
Assignees
Labels
Milestone

Comments

@markelog
Copy link
Member

Syntax:

To be written.

Spec:

https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array-initializer

Relevant AST interfaces (from https://github.com/estree/estree):

interface SpreadElement <: Node {
    type: "SpreadElement";
    argument: Expression;
}

extend interface CallExpression {
    arguments: [ Expression | SpreadElement ];
}

Early Errors:

The following early errors should be detected: (to be written)

Related Tasks:

  • Error message
@michaelficarra
Copy link
Contributor

Spread is not just allowed in function argument position, but also as an array initialiser element.

[...a]

@mikesherov mikesherov mentioned this issue Apr 29, 2015
25 tasks
@markelog
Copy link
Member Author

markelog commented May 8, 2015

As i see it, spread operator is not supported for the function calls. Arrays and fd are.

@markelog
Copy link
Member Author

markelog commented May 8, 2015

So for the expression a(...b) correct AST should look like that -

{
  "type": "Program",
  "body": [
    {
      "type": "ExpressionStatement",
      "expression": {
        "type": "CallExpression",
        "callee": {
          "type": "Identifier",
          "name": "a"
        },
        "arguments": [
          {
            "argument": {
              "name": "b",
              "type": "Identifier",
            },
            "type": "SpreadElement",
          }
        ]
      }
    }
  ]
}

@mikesherov, @ariya ?

@markelog
Copy link
Member Author

markelog commented May 8, 2015

Does cherry-picking these commits is sufficient?

/cc @Benvie

@markelog
Copy link
Member Author

@mikesherov @ariya could one of you confirm my proposal?

@ariya
Copy link
Contributor

ariya commented May 19, 2015

@markelog Probably not. Much has changed since and master has diverged much vs the old harmony branch.

@ariya ariya changed the title Implement spread arguments ES6: Spread Element Jun 22, 2015
@ariya ariya added the es6 label Jun 22, 2015
@ariya ariya self-assigned this Jun 22, 2015
@ariya ariya added this to the 2.4 milestone Jun 22, 2015
@ariya
Copy link
Contributor

ariya commented Jun 22, 2015

Apparently spread element for array initializer has been done by @ikarienator as part of #1045. Thus, let's scope this only for function argument.

@ariya ariya changed the title ES6: Spread Element ES6: Spread Element (for function argument) Jun 22, 2015
ariya added a commit to ariya/esprima that referenced this issue Jun 22, 2015
ariya added a commit to ariya/esprima that referenced this issue Jun 23, 2015
@ariya ariya closed this as completed in 2199b84 Jun 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants