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

Closed
lmartorella opened this issue May 30, 2023 · 2 comments · Fixed by #5826
Closed

[ES6] Bug in rename and destructuring #5792

lmartorella opened this issue May 30, 2023 · 2 comments · Fixed by #5826
Labels

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

@alexlamsl alexlamsl added the bug label Jun 3, 2024
@alexlamsl
Copy link
Collaborator

Thanks for the detailed report − investigating.

alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jun 5, 2024
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jun 5, 2024
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jun 5, 2024
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jun 5, 2024
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jun 5, 2024
@alexlamsl
Copy link
Collaborator

Patch released in uglify-js@3.18.0

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

Successfully merging a pull request may close this issue.

2 participants