Skip to content

JavaScript reports errors on on async shorthand with for-of loop in lambda object #19134

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

Closed
mjbvz opened this issue Oct 12, 2017 · 1 comment
Closed
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Oct 12, 2017

From microsoft/vscode#36153

TypeScript Version: 2.6.0

Code
For the JS

let validLambda = () => ({
    async bla() {
        for ( let i of [] ) {
            console.log(i)
        }
    }
})

Expected behavior:
No errors

Actual behavior:

The following errors are reported:

[Trace  - 10:41:27] Event received: syntaxDiag (0).
Data: {
    "file": "/Users/matb/projects/san/test.js",
    "diagnostics": [
        {
            "start": {
                "line": 2,
                "offset": 11
            },
            "end": {
                "line": 2,
                "offset": 14
            },
            "text": "'=' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 2,
                "offset": 17
            },
            "end": {
                "line": 2,
                "offset": 18
            },
            "text": "',' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 3,
                "offset": 13
            },
            "end": {
                "line": 3,
                "offset": 14
            },
            "text": "':' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 3,
                "offset": 19
            },
            "end": {
                "line": 3,
                "offset": 20
            },
            "text": "')' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 3,
                "offset": 21
            },
            "end": {
                "line": 3,
                "offset": 23
            },
            "text": "'=' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 3,
                "offset": 27
            },
            "end": {
                "line": 3,
                "offset": 28
            },
            "text": "',' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 3,
                "offset": 29
            },
            "end": {
                "line": 3,
                "offset": 30
            },
            "text": "'=>' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 6,
                "offset": 5
            },
            "end": {
                "line": 6,
                "offset": 6
            },
            "text": "Declaration or statement expected.",
            "code": 1128,
            "category": "error"
        },
        {
            "start": {
                "line": 7,
                "offset": 1
            },
            "end": {
                "line": 7,
                "offset": 2
            },
            "text": "Declaration or statement expected.",
            "code": 1128,
            "category": "error"
        },
        {
            "start": {
                "line": 7,
                "offset": 2
            },
            "end": {
                "line": 7,
                "offset": 3
            },
            "text": "Declaration or statement expected.",
            "code": 1128,
            "category": "error"
        }
    ]
}
@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Oct 12, 2017
@ghost ghost added the Bug A bug in TypeScript label Oct 12, 2017
@ghost
Copy link

ghost commented Oct 12, 2017

Looks like a parser bug. It works if either the for-of or the lambda is removed. Works with a for(;;) loop but not a for-in loop. Not exclusive to JavaScript.

@mhegazy mhegazy added this to the TypeScript 2.7 milestone Oct 12, 2017
@weswigham weswigham assigned ghost and unassigned weswigham Oct 13, 2017
@ghost ghost closed this as completed in #19158 Nov 13, 2017
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Nov 13, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

3 participants