Esprima allows to create class in single-statements #1824

Open
smelukov opened this Issue Apr 7, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@smelukov

smelukov commented Apr 7, 2017

Steps to reproduce

esprima.parse('if(1)class A{}')

Parsed into:

{
    "type": "Program",
    "body": [
        {
            "type": "IfStatement",
            "test": {
                "type": "Literal",
                "value": 1,
                "raw": "1"
            },
            "consequent": {
                "type": "ExpressionStatement",
                "expression": {
                    "type": "ClassExpression",
                    "id": {
                        "type": "Identifier",
                        "name": "A"
                    },
                    "superClass": null,
                    "body": {
                        "type": "ClassBody",
                        "body": []
                    }
                }
            },
            "alternate": null
        }
    ],
    "sourceType": "script"
}

But should fail becase this is not valid code.

Expected output

Exception

Actual output

No exception

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