babel/babel

[Bug]: Transform block scoping fails with for in statement inside loop

luiscubal opened this issue · 1 comments

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

I was able to replicate this issue in babeljs.io with the following code:

function w() {
    for (let i = 0; i < y; i++) {
        let outer = {}
        for (var key in someObj) {
            let x = () => outer;
        }
    }
}

Configuration file name

No response

Configuration

Using the transform-block-scoping plugin only.

Current and expected behavior

Expected Babel to be able to parse & transform the code without throwing any exceptions.

Actual behavior is an error:

/repl.js: Property left of ForInStatement expected node to be of a type ["VariableDeclaration","LVal"] but instead got undefined

Environment

I could replicate this issue in babeljs.io

Possible solution

No response

Additional context

No response

Hey @luiscubal! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.