Skip to content

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

@luiscubal

Description

@luiscubal

💻

  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions