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

Can't parse { async, foo } #1847

Closed
ex1st opened this Issue Aug 11, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@ex1st

ex1st commented Aug 11, 2017

Before version 4.0 this code was valid.

Steps to reproduce

esprima.parse(`
const async = function () {};
const inherits = function () {};
exports['default'] = {
    async,
    inherits
};
`)

Expected output

{
    "type": "Program",
    "body": [
        {
            "type": "VariableDeclaration",
            "declarations": [
                {
                    "type": "VariableDeclarator",
                    "id": {
                        "type": "Identifier",
                        "name": "async"
                    },
                    "init": {
                        "type": "FunctionExpression",
                        "id": null,
                        "params": [],
                        "body": {
                            "type": "BlockStatement",
                            "body": []
                        },
                        "generator": false,
                        "expression": false,
                        "async": false
                    }
                }
            ],
            "kind": "const"
        },
        {
            "type": "VariableDeclaration",
            "declarations": [
                {
                    "type": "VariableDeclarator",
                    "id": {
                        "type": "Identifier",
                        "name": "inherits"
                    },
                    "init": {
                        "type": "FunctionExpression",
                        "id": null,
                        "params": [],
                        "body": {
                            "type": "BlockStatement",
                            "body": []
                        },
                        "generator": false,
                        "expression": false,
                        "async": false
                    }
                }
            ],
            "kind": "const"
        },
        {
            "type": "ExpressionStatement",
            "expression": {
                "type": "AssignmentExpression",
                "operator": "=",
                "left": {
                    "type": "MemberExpression",
                    "computed": true,
                    "object": {
                        "type": "Identifier",
                        "name": "exports"
                    },
                    "property": {
                        "type": "Literal",
                        "value": "default",
                        "raw": "'default'"
                    }
                },
                "right": {
                    "type": "ObjectExpression",
                    "properties": [
{
                            "type": "Property",
                            "key": {
                                "type": "Identifier",
                                "name": "async"
                            },
                            "computed": false,
                            "value": {
                                "type": "Identifier",
                                "name": "async"
                            },
                            "kind": "init",
                            "method": false,
                            "shorthand": true
                        },
                        {
                            "type": "Property",
                            "key": {
                                "type": "Identifier",
                                "name": "inherits"
                            },
                            "computed": false,
                            "value": {
                                "type": "Identifier",
                                "name": "inherits"
                            },
                            "kind": "init",
                            "method": false,
                            "shorthand": true
                        }                        
                    ]
                }
            }
        }
    ],
    "sourceType": "script"
}

Actual output

Error: Line 4: Unexpected token ,

Relevant references

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer
Shorthand property names (ES2015)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function

@ariya ariya self-assigned this Aug 11, 2017

@ariya ariya added the defect label Aug 11, 2017

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 3, 2017

@ariya Is this issue going to be fixed? I know I can just send a PR, but after observing the repo for a few months I noticed the PR will not be merged.

There exist issue with ({async})) too.

BTW: Is this repo stall now?

ghost commented Sep 3, 2017

@ariya Is this issue going to be fixed? I know I can just send a PR, but after observing the repo for a few months I noticed the PR will not be merged.

There exist issue with ({async})) too.

BTW: Is this repo stall now?

@mikesherov

This comment has been minimized.

Show comment
Hide comment
@mikesherov

mikesherov Sep 3, 2017

Member

@nowindowsowrking, what ever happened to that parser you were going to release? It sounded interesting.

Member

mikesherov commented Sep 3, 2017

@nowindowsowrking, what ever happened to that parser you were going to release? It sounded interesting.

@ariya

This comment has been minimized.

Show comment
Hide comment
@ariya

ariya Sep 5, 2017

Contributor

@nowindowsowrking It's going to be fixed whenever there is a volunteer (could be anyone) to fix it.

We've been through this before, there is no need to rehash it again and explain how this project operates all the time. Please use another forum for such a meta discussion.

Contributor

ariya commented Sep 5, 2017

@nowindowsowrking It's going to be fixed whenever there is a volunteer (could be anyone) to fix it.

We've been through this before, there is no need to rehash it again and explain how this project operates all the time. Please use another forum for such a meta discussion.

@ariya ariya closed this in 1e6ca4b Sep 9, 2017

ariya added a commit to ariya/esprima that referenced this issue Sep 16, 2017

ariya added a commit that referenced this issue Sep 21, 2017

ariya added a commit to ariya/esprima that referenced this issue Jun 15, 2018

ariya added a commit to ariya/esprima that referenced this issue Jun 15, 2018

ariya added a commit to ariya/esprima that referenced this issue Jun 16, 2018

ariya added a commit to ariya/esprima that referenced this issue Jun 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment