Skip to content

[Bug]: forward reference (use before definition) in switch statement #15151

@p51lee

Description

@p51lee

💻

  • Would you like to work on a fix?

How are you using Babel?

Other (Next.js, Gatsby, vue-cli, ...)

Input code

switch ( x ) { default : let x { ; } ; }

Configuration file name

No response

Configuration

No response

Current and expected behavior

In the input code, ReferenceError is expected but the transpiled code terminates without any error.

$ node input.js
output.js:1: ReferenceError: x is not defined
switch ( x ) { default : let x ; }
         ^
ReferenceError: x is not defined
    at output.js:1:10
$ node output.js # no error

Environment

Reproductions on Babel's own REPL

Possible solution

It might be possible to solve this issue by changing var x into var _x.

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