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

Wrong parsing of function returning a multi-line template string #1869

Closed
AurelienRibon opened this Issue Oct 24, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@AurelienRibon

AurelienRibon commented Oct 24, 2017

Steps to reproduce

Parse the following script:

function foo() {
  return `a
  b`;
}

Actual output

Here is the body of the FunctionDeclaration item:

{
    "type": "BlockStatement",
    "body": [
        {
            "type": "ReturnStatement",
            "argument": null                    <------------ ???
        },
        {
            "type": "ExpressionStatement",
            "expression": {
                "type": "TemplateLiteral",
                "quasis": [
                    {
                        "type": "TemplateElement",
                        "value": {
                            "raw": "a\n  b",
                            "cooked": "a\n  b"
                        },
                        "tail": true
                    }
                ],
                "expressions": []
            }
        }
    ]
}

Expected output

The ReturnStatement item should not have a null argument, but the TemplateLiteral that appears as the next statement.

@ariya

This comment has been minimized.

Show comment
Hide comment
@ariya

ariya Nov 20, 2017

Contributor

Thanks for the report @AurelienRibon! I believe this is a duplicate of #1829.

Contributor

ariya commented Nov 20, 2017

Thanks for the report @AurelienRibon! I believe this is a duplicate of #1829.

@ariya ariya closed this Nov 20, 2017

@AurelienRibon

This comment has been minimized.

Show comment
Hide comment
@AurelienRibon

AurelienRibon Nov 20, 2017

Thanks for fixing it! 👍

AurelienRibon commented Nov 20, 2017

Thanks for fixing it! 👍

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