Skip to content
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

[ES6] Bug in rename and destructuring #5792

Open
lmartorella opened this issue May 30, 2023 · 0 comments
Open

[ES6] Bug in rename and destructuring #5792

lmartorella opened this issue May 30, 2023 · 0 comments

Comments

@lmartorella
Copy link

Uglify version 3.17.4

JavaScript input

This code is already mangled from a previous pass, but it is actually the input in this test case.

source-file.js:

function f(e) {
    const {
        p3: {
            p4: o   // Note the destructuring of `e` to extract e.p3.p4 and put in `o`
        }
    } = e;
    switch (o) {  // o is used
        case "X":
            const o = this.z;  // `o` is overwritten in the local scope (legit in ES)
            break;
    }
}

The uglifyjs CLI command executed or minify() options used.

npx uglifyjs --compress --mangle -- source-file.js

JavaScript output or error produced.

function f(n){const{}=n["p3"];if("X"===b){const b=this.z}}

Note the empty destructuring, probably the intention was to produce b, that is used in the switch branch (then correctly optimized with an if).

Thanks, L

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant